def subprocess_visible_devices(gpus):
 if (not isinstance(gpus, list)):
  raise ValueError('gpus should be a list')
 gpus = [int(g) for g in gpus]
 old_cvd = os.environ.get('CUDA_VISIBLE_DEVICES', None)
 if (old_cvd is None):
  real_gpus = gpus
 else:
  map_visible_to_real = {}
  for (visible, real) in enumerate(old_cvd.split(',')):
   map_visible_to_real[visible] = int(real)
  real_gpus = []
  for visible_gpu in gpus:
   real_gpus.append(map_visible_to_real[visible_gpu])
 return ','.join((str(g) for g in real_gpus))

def subprocess_visible_devices ( gpus ) : if ( not isinstance ( gpus , list ) ) : raise ValueError ( 'gpus should be a list' ) gpus = [ int ( g ) for g in gpus ] old_cvd = os . environ . get ( 'CUDA_VISIBLE_DEVICES' , None ) if ( old_cvd is None ) : real_gpus = gpus else : map_visible_to_real = { } for ( visible , real ) in enumerate ( old_cvd . split ( ',' ) ) : map_visible_to_real [ visible ] = int ( real ) real_gpus = [ ] for visible_gpu in gpus : real_gpus . append ( map_visible_to_real [ visible_gpu ] ) return ',' . join ( ( str ( g ) for g in real_gpus ) )
calculates cuda_visible_devices for a subprocess .