0

I have done a computation using CUDA and it takes around 12 minutes to complete the whole computation. I am using this command in a .sh file to run the program:

CUDA_VISIBLE_DEVICES=0 ./a1.out | tee -a output.txt &
CUDA_VISIBLE_DEVICES=1 ./a2.out | tee -a output.txt &
CUDA_VISIBLE_DEVICES=2 ./a3.out | tee -a output.txt &
CUDA_VISIBLE_DEVICES=3 ./a4.out | tee -a output.txt &
CUDA_VISIBLE_DEVICES=4 ./a5.out | tee -a output.txt &
CUDA_VISIBLE_DEVICES=5 ./a6.out | tee -a output.txt &

Now I want to show a progress bar for this process in the command line window for user. Is there is any way to do it?

David Foerster
  • 36,890
  • 56
  • 97
  • 151
agangwal
  • 123

1 Answers1

3

Use pv(1) in line mode:

COMMAND | pv --line-mode --size 1000 >> output.txt

or shorter

COMMAND | pv -ls 1000 >> output.txt

-s/--size sets the number of expected output units (bytes by default or lines in line mode).

If you want to capture the output and display the progress of multiple commands running in parallel you can do so with a compound statement:

{ COMMAND1 & COMMAND2 & COMMAND3; } | pv -ls 1000 >> output.txt

In that case you need to specify the number of expected output units of all commands in total.

Demo

for i in {1..200}; do sleep 0.1; echo "$i"; done | pv -ls 200 > /dev/null
David Foerster
  • 36,890
  • 56
  • 97
  • 151