def gpu_count():
 try:
  output = subprocess.check_output('nvidia-smi -L')
  return len(output.strip().split('\n'))
 except:
  return 0

def gpu_count ( ) : try : output = subprocess . check_output ( 'nvidia-smi -L' ) return len ( output . strip ( ) . split ( '\n' ) ) except : return 0
counts the number of cuda-capable gpus .