我在我的机器中添加了一张GeForce GTX 1080 Ti显卡(运行Ubuntu 18.04和带有Python 3.7的Anaconda),以便在使用PyTorch时利用GPU。两张显卡都被正确识别:
$ lspci | grep VGA
03:00.0 VGA compatible controller: NVIDIA Corporation GF119 [NVS 310] (reva1)
04:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
NVS 310处理我的2个显示器设置,我只想利用1080来运行PyTorch。我还安装了目前存储库中最新的NVIDIA驱动程序,这似乎很好:
$ nvidia-smi
Sat Jan 19 12:42:18 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.87 Driver Version: 390.87 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 NVS 310 Off | 00000000:03:00.0 N/A | N/A |
| 30% 60C P0 N/A / N/A | 461MiB / 963MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:04:00.0 Off | N/A |
| 0% 41C P8 10W / 250W | 2MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+
根据NVIDIA文档,390.xx驱动版本可以运行CUDA 9.1(9.1.85)。由于这也是Ubuntu存储库中的版本,因此我只需使用以下命令安装CUDA Toolkit:
$ sudo apt-get-installed nvidia-cuda-toolkit
再次确认,这似乎没问题:
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
and$ apt-cache policy nvidia-cuda-toolkit
nvidia-cuda-toolkit:
Installed: 9.1.85-3ubuntu1
Candidate: 9.1.85-3ubuntu1
Version table:
*** 9.1.85-3ubuntu1 500
500 http://sg.archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
100 /var/lib/dpkg/status
最后,我使用conda从头安装了PyTorch。
conda install pytorch torchvision -c pytorch
据我所知,也存在错误:
$ conda list
...
pytorch 1.0.0 py3.7_cuda9.0.176_cudnn7.4.1_1 pytorch
...
然而,PyTorch似乎无法找到CUDA:
$ python -c 'import torch; print(torch.cuda.is_available())'
False
具体而言,如果我强制将PyTorch中的张量x
转换为CUDA格式,使用x.cuda()
,则会出现以下错误:
Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from 82 http://...
我在这里缺少什么?我是新手,但我认为我已经检查了Web相当多的内容,以查找任何类似于NVIDIA驱动程序和CUDA工具包版本的注意事项?
编辑:PyTorch的一些更多输出:
print(torch.cuda.device_count()) # --> 0
print(torch.cuda.is_available()) # --> False
print(torch.version.cuda) # --> 9.0.176
vectorAdd
或bandwidthTest
这样的示例代码。如果它们不能正确工作,那么你的CUDA安装就有问题了。 - Robert Crovella