def QueryNumberOfGpus(vm):
  """Returns the number of NVIDIA GPUs on the system.

  Args:
    vm: Virtual machine to query.

  Returns:
    Integer indicating the number of NVIDIA GPUs present on the vm.
  """
  stdout, _ = vm.RemoteCommand('sudo nvidia-smi --query-gpu=count --id=0 '
                               '--format=csv', should_log=True)
  return int(stdout.split()[1])