我在我的机器(运行 Ubuntu 18.04 和 Anaconda 和 Python 3.7)中添加了一个 GeForce GTX 1080 Ti,以便在使用 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 |
+-----------------------------------------------------------------------------+
驱动程序版本 390.xx 允许根据 NVIDIA docs 运行 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
和
$ 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
使用 x.cuda()
到 CUDA我收到错误:Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from 82 http://...
我在这里缺少什么?我是新手,但我想我已经在网上查了很多,找到了像 NVIDIA 驱动程序和 CUDA 工具包版本这样的警告?
编辑: PyTorch 的更多输出:
print(torch.cuda.device_count()) # --> 0
print(torch.cuda.is_available()) # --> False
print(torch.version.cuda) # --> 9.0.176
最佳答案
由于您有两个图形卡,选择一个卡 ID CUDA_VISIBLE_DEVICES=GPU_ID
应该按照这个解决问题 explanation .
关于python - 为什么 PyTorch 找不到我的 NVIDIA 驱动程序来支持 CUDA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54264338/