Pytorch查看GPU信息

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

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/3b2c110bbb.html