Parallel on unix with screen - shell

Is there a way to run in parallel? I can manually start screens, but I need to start up 30.
I attempted to do it by hand (stupid yeah) but I got confused halfway through and decided I better ask stackoverflow.
#!/bin/bash --login
2
3
4
5
6 avida=~/avida/cbuild/bin/avida
7 skeleton_dir=~/cse845/no_pred
8 # wd=/mnt/scratch/cse845_avida/predator_sim
9 wd=~/cse845/no_predator_editor_sim_wd
10
11 for i in {1..30}
12 do
13 screen
14
15
16 sim_num=${i}
17 sim_dir=${wd}/sim_$sim_num
18 mkdir $sim_dir
19 cd $sim_dir
20 cp ${skeleton_dir}/*.cfg ${skeleton_dir}/*.org ./
21 $avida &> avida_log.txt
22# Here I would like to do the equivalent of exiting screen manually, ^A, d
23 done

Here is how to start 3 at the same time in a shell script (the -d -m starts them in the background)
screen -s "name1" -c ~/screen/name1.screenrc -d -m
screen -s "name2" -c ~/screen/name2.screenrc -d -m
screen -s "name3" -c ~/screen/name3.screenrc -d -m
Then you could have a variable number of tabs/windows within each screen, specified in your screenrc files. (with -t).
See example screenrc file designed to work well with emacs: https://github.com/startup-class/dotfiles/blob/master/.screenrc
This is the only Section about specifying which tabs/windows per socket.
# 2.3) Autoload two screen tabs for emacs/bash.
screen -t emacs 0
screen -t bash 1
So when you do screen -ls you would get
There are screens on:
4149.name1 (07/10/13 22:18:44) (Detached)
4018.name2 (07/10/13 22:18:23) (Detached)
3882.name3 (07/10/13 22:17:08) (Detached)
3 Sockets in /var/run/screen/S-yourid.
And then if you wanted to connect to name1, you'd do screen -r 4149 or screen -r name1

I see two things right away:
You are missing the necessary backslashes to escape your newlines in the screen command arguments.
You need to tell screen to run in the background. See the -d and -m options.

Related

Running different tasks on individual resource sets within same node

I asked about an issue I had with this using a different approach (Having issues running mpi4py on large HPC system. Receving startup errors and sometimes variable errors), however I'm currently attempting two other approaches. With no success. All examples below still put the same task on each of the six resource sets.
Background: I'm attempting to distribute predictions across resource sets on a node. Each resource set contains 1 gpu and 7 cpus and there are six sets per node. Once a RS task completes, it should move on to the next prediction on in a list (part00.lst through part05.lst; in theory one per RS)
First approach looks something like this (a submission bash script calls this using jsrun -r6 -g1 -a1 -c7 -b packed:7 -d packed -l gpu-cpu):
#!/bin/bash
output=/path/ ##where completed predictions will be collected
for i in {0..5}; do
target=part0${i}.lst
........ ##the singularity job script to execute using $target and $output variables
done
The next attempt is using simultaneous jobs steps via UNIX backgrounding (which others have been able to appropriate to do similar things that I wish to do, but for different jobs and tasks). Here I created six separate bash files with each corresponding input file ($target aka part00.lst through part05.lst):
#!/bin/bash
## Various submission flags here
for i in {0..5}; do
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_0${i}.sh &
done
wait
I also attempted just hardcoding the six separate bash files:
#!/bin/bash
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_00.sh &
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_01.sh &
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_02.sh &
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_03.sh &
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_04.sh &
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_05.sh &
wait
Thanks for any help! I'm still quite new to all of this!
Okay, attempt number two using simultaneous job steps/UNIX process backgrounding was nearly correct!
It now works. An example for one node:
Submission script:
#!/bin/bash
## Various submission flags here
for i in {0..5}; do
jsrun -r 6 -g 1 -a 1 -c 7 -brs -d packed -l gpu-cpu bash batch_run_0${i}.sh &
done
wait
It was only a matter of incorrect flags (-n 1 -r 1, not -n 1 -r 6).

Can't return to command line

Total noob question - it has me stumped. I'm using SOX to create spectrograms of images files, and it's been working fine, but now when I try to execute it just gives me a carat prompt and does nothing (>)...anything I type seems to have no effect. Command-. does get me back to the normal prompt. Here's what it looks like on my screen:
Last login: Tue Oct 24 11:39:33 on ttys000
Scotts-iMac:~ scottwhittle$ cd /Users/scottwhittle/Desktop/Belize\Test2
Scotts-iMac:Belize Test2 scottwhittle$ for file in *.mp3
> do
> outfile="${file%.*}.png"
> sox "$file" -n spectrogram r -l -m -d "$title_in_pic" -o ”$outfile" -X 5000 -y 513 norm
> done
> help!
> nothing I type seems to do anything
>
What's confusing is that it works sometimes and not others. One thing I am doing is editing the command in TextEdit to change parameters, and then copying and pasting to terminal. Is thing the issue? Thanks for any and all help.

Windows Console Output from Waifu2x-caffe unintelligible

I am using Waif2x to upscale a series of images, but I am having a problem with the command I am running. I would try to troubleshoot it myself, yet I can't not make use of the error output. It reads:
âGâëü[: âéâfâïâtâ#âCâïé¬èJé»é▄é╣é±é┼é╡é╜
I think it is in Japanese as evidenced by Waifu2x's Github page. I also believe it is the same everytime, yet I cant know for sure. I am using a English Computer, and I am also a English speaker, so I really need to know what it is in English or something I can Google translate.
I have already tried the solution here as evidenced by looking at the regedit, where Name=00, Data=Consolas.
Regarding my specific problem, the Command I am typing into cmd is
waifu2x-caffe-cui -i "C:\Users\Christian\workspace\CodeLyokoUpscaleing\bin\480Frames" -e png -l png -m noise_scale -d 16 -h 1440 -n 1 -p cudnn -c 256 -b 1 --auto_start 1 --auto_exit 1 --no_overwrite 1 -y upconv_7_anime_style_art_rgb -o "C:\Users\Christian\workspace\CodeLyokoUpscaleing\bin\1440Frames"
I really think it should work as I converted it from another batch file I created that contained variables instead of file paths
waifu2x-caffe-cui -i "%~dp0480Frames" -e png -l png -m noise_scale -d 16 -h 1440 -n 1 -p cudnn -c 256 -o "%~dp01440Frames" --auto_start 1 --auto_exit 1 --no_overwrite 1 -y upconv_7_anime_style_art_rgb
But I still get the weird output.
How can I see what the error is?

Keep the gnome terminal open after the program is finished

This script opens a gnome terminal and 4 tabs in it , but once the program finishes the tabs gets closed so i can't see the output. It doesn't happen when i run each program manually. How can keep the tab open , even when the program is finished .
gnome-terminal --tab -e "optirun yarpserver" \
--tab -e "sh -c 'sleep 20 ; optirun iCub_SIM'" \
--tab -e "sh -c 'sleep 86 ; optirun simCartesianControl'" \
--tab -e "sh -c 'sleep 116 ; optirun iKinCartesianSolver --context simCartesianControl/conf --part left_arm'" \
Not sure how to do it on the command line (man gnome-terminal doesn't seem to indicate a specific option for that, but you can start a gnome-terminal, set specific options (one of which would be "When command exits: Hold the terminal open"), and save your settings as a specific profile. There is a command-line option for selecting a specific profile to use, so that should accomplish what you want.

using wmctrl to close windows

Can I close a window using wmctrl that is running in wine on Ubuntu?
For context:
$ wmctrl -m
Name: compiz
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF
Also:
$ wmctrl -l
0x0240a3be -1 mjol N/A
0x02000003 0 mjol Top Expanded Edge Panel
0x0200004c 0 mjol Bottom Expanded Edge Panel
0x01e00024 0 mjol x-nautilus-desktop
0x04800253 0 mjol using wmctrl to close windows - Stack Overflow - Google Chrome
0x03c0c8c3 0 mjol Terminal
0x03c53f25 0 mjol Terminal
0x04400001 0 mjol Untitled - SketchUp
0x04400003 0 mjol Instructor
0x04400009 0 mjol SketchUp
The window I want to close is the last one:
0x04400009 0 mjol SketchUp
I've tried the following:
$ wmctrl -c "SketchUp"
$ wmctrl -c 0x04400009
$ wmctrl -i 0x04400009
$ wmctrl -c -i 0x04400009
But nothing works.
Maybe a little late, but first seen now.
Reading the info for wmctrl, it says that the correct syntax is 'options' before actions, and -i is an option, -c an action. Try wmctrl -i -c 0x04400009
I was having the same question and just found how to do it!
Here's the one-liner that will gracefully close all Google Chrome windows:
wmctrl -lix |grep 'Google-chrome'|cut -d ' ' -f 1 |xargs -i% wmctrl -i -c %
Explanation:
wmctrl -lix list all windows including their Id and Class
grep 'Google-chrome' grep only windows with Google-chrome class (this is important because when you use a site with the app/shortcut option it gets it own class like 'calendar.google.com.Google-chrome'
cut -d ' ' -f 1 cuts the output to get only the IDs column
xargs -i% wmctrl -i -c % passes each ID to the wmctrl using the ID option -i and close command -c
Note: the xargs only worked when I used the -i option to specify replace-string. Otherwise it would only act on the first item.
According to the man page, you should select the window first using a select option, like -r and -a, exemple :
$ wmctrl -l
0x01800006 0 hostname Terminal - byobu
$ wmctrl -a Terminal
Here indeed selects (and raises + focus due to -a) the terminal window.
Then you can use a resize / move option such as -e gravity,X,Y,width,height
As for your question, I just tested this :
$ wmctrl -l
0x01800006 0 machine_hostname - byobu
0x06800002 0 moe Microsoft Excel - Classeur1
And Excel (obviously running in Wine) closed gracefully when I entered
$ wmctrl -c Microsoft
Plenty of additional info here.

Resources