Commit c941633f authored by Ilija Radosavovic's avatar Ilija Radosavovic Committed by Facebook Github Bot

Specify GPU inds to use for multi-gpu testing

Reviewed By: rbgirshick

Differential Revision: D6784702

fbshipit-source-id: b5f81d858f9e9d33c048c39f849d0e29e8db3cb1
parent efc0c0ed
...@@ -49,10 +49,19 @@ def process_in_parallel(tag, total_range_size, binary, output_dir): ...@@ -49,10 +49,19 @@ def process_in_parallel(tag, total_range_size, binary, output_dir):
subprocess_env = os.environ.copy() subprocess_env = os.environ.copy()
processes = [] processes = []
subinds = np.array_split(range(total_range_size), cfg.NUM_GPUS) subinds = np.array_split(range(total_range_size), cfg.NUM_GPUS)
for i in range(cfg.NUM_GPUS): # Determine GPUs to use
cuda_visible_devices = os.environ.get('CUDA_VISIBLE_DEVICES')
if cuda_visible_devices:
gpu_inds = map(int, cuda_visible_devices.split(','))
assert -1 not in gpu_inds, \
'Hiding GPU indices using the \'-1\' index is not supported'
else:
gpu_inds = range(cfg.NUM_GPUS)
# Run the binary in cfg.NUM_GPUS subprocesses
for i, gpu_ind in enumerate(gpu_inds):
start = subinds[i][0] start = subinds[i][0]
end = subinds[i][-1] + 1 end = subinds[i][-1] + 1
subprocess_env['CUDA_VISIBLE_DEVICES'] = str(i) subprocess_env['CUDA_VISIBLE_DEVICES'] = str(gpu_ind)
cmd = '{binary} --range {start} {end} --cfg {cfg_file} NUM_GPUS 1' cmd = '{binary} --range {start} {end} --cfg {cfg_file} NUM_GPUS 1'
cmd = cmd.format( cmd = cmd.format(
binary=shlex_quote(binary), binary=shlex_quote(binary),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment