import torch

 

#cuda是否可用
torch.cuda.is_available()

结果:

True

 

#返回当前设备索引
torch.cuda.current_device()

结果:

0

 

#返回GPU的数量
torch.cuda.device_count()

结果:

1

 

#返回gpu名字,设备索引默认从0开始
torch.cuda.get_device_name(0)
'NVIDIA TITAN Xp'

 

#设置当前设备。
device = "cuda:0"
torch.cuda.set_device(device)

 

相关文章:

  • 2021-09-28
  • 2021-04-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2021-06-25
  • 2022-12-23
  • 2021-07-30
  • 2022-01-05
  • 2022-12-23
相关资源
相似解决方案