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

猜你喜欢

转载自blog.csdn.net/u014486518/article/details/129320525