Skip to content

Instantly share code, notes, and snippets.

@fanyix
Created December 6, 2019 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fanyix/9db420810c7391fc3bf18f146ddc7db1 to your computer and use it in GitHub Desktop.
Save fanyix/9db420810c7391fc3bf18f146ddc7db1 to your computer and use it in GitHub Desktop.
Launching script
import subprocess
import os
import numpy as np
import time
# number of procs
file = 'download.py'
sleep_time = 5
proc_N = 8
# gpu_id = np.array([0,1,2,3,0,1,2,3,0,1,2,3])
# assert proc_N == len(gpu_id)
# launch processes
for proc in range(0, proc_N):
my_env = os.environ.copy()
# my_env["CUDA_VISIBLE_DEVICES"] = '%g' % gpu_id[proc]
subprocess.Popen(['python', '%s' % file, '%d' % proc_N, '%d' % proc], env=my_env)
print('%g/%g process launched' % (proc, proc_N))
time.sleep(sleep_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment