1、查看cuda是否可用:torch.cuda.is_available()
>>> import torch
>>> torch.cuda.is_available()
True
2、查看GPU数量:torch.cuda.device_count()
>>> torch.cuda.device_count()
1
3、查看GPU型号,设备索引默认从0开始:torch.cuda.get_device_name(0)
>>> torch.cuda.get_device_name(0)
'NVIDIA T4 32GB'
4、查看当前设备索引:torch.cuda.current_device()
>>> torch.cuda.current_device()
0
文章出处登录后可见!
已经登录?立即刷新