How do I limit using one CPU per python processes launched via gnu parallel?
If I run this script
$ seq 1 4 | taskset -c 0-3 parallel -j4 -u &lt;my_bash_script.sh&gt;

Then each python process contained in the &lt;my_bash_script.sh&gt; runs on multiple cpus instead of one. The python function use both numpy and pytorch. So the option taskset -c 0-4 impose the max number of CPUs but it doesn't guarantee that each process will be limited to one CPU.
I've tried
$ export OPENBLAS_NUM_THREADS=1
$ export MKL_NUM_THREADS=1

but it didn't work
I've also added to the python script
import mkl
mkl.set_num_threads(1)

but it didn't help

Use jobslot:
$ seq 1 4 | parallel -j4 -u taskset -c {%} &lt;my_bash_script.sh&gt;

Jobslot is built for this: Imagine you have a lot more than 4 jobs. If you then give every 4th job to cpu 4, then you risk that every 4th job is shorter than the others. In which case cpu 4 will be idling even if there are more jobs to be run.
Jobslot does not pass every 4th job to cpu 4. Instead it looks a which cpu (or rather jobslot) that finished a job, and then starts a new job on that cpu.
(Also: Since you are using -u you should learn the difference between --group (default) and --linebuffer (which is often what you really want when using -u)).
