I can run a CuPy script with different parameters on different GPUs concurrently very easily from the terminal of from a bash script as:
export CUDA_VISIBLE_DEVICES="0"; python3 mycode.py arg1 &
export CUDA_VISIBLE_DEVICES="0"; python3 mycode.py arg2 &
I can also do the same using subprocesses from a python scipt:
import subprocess
subprocess.run('export CUDA_VISIBLE_DEVICES="0"; python3 mycode.py arg1 &
export CUDA_VISIBLE_DEVICES="0"; python3 mycode.py arg2 &', shell=True)
I tried to use function version with selecting device, but it does not run concurrently
with cupy.cuda.Device(0):
mycode(arg1)
with cupy.cuda.Device(1):
mycode(arg2)
Is there a more elegant solution?
Andras