pytorch使用GPU确认

■使用pytorch代码检查GPU信息
In [1]: import torch

In [2]: torch.cuda.current_device()
Out[2]: 0

In [3]: torch.cuda.device(0)
Out[3]:

In [4]: torch.cuda.device_count()
Out[4]: 1

In [5]: torch.cuda.get_device_name(0)
Out[5]: 'GeForce GTX 1080 Ti'

In [6]: torch.cuda.is_available()
Out[6]: True

ln [7]:torch.version.cuda
out[7]: '9.2'

使用Linux命令确认GPU信息
■显卡版本确认
cat /proc/driver/nvidia/version

■cuda版本确认
nvcc -V
或者
cat /usr/local/cuda/version.txt

■通过nvidia-smi确定cuda版本


image.png

■各版本兼容性

image.png

上面的图片来自链接(最新情况请参照):
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html

你可能感兴趣的:(pytorch使用GPU确认)