CUDA运行时未知错误,也许是驱动程序问题? CUDA看不到我的GPU

时间:2019-05-27 13:56:21

标签: python tensorflow pytorch nvidia

我的代码目前非常简单:

import torch 
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
torch.cuda.current_device()

    ---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-20-3380d2c12118> in <module>
----> 1 torch.cuda.current_device()

~/.conda/envs/tensorflow/lib/python3.6/site-packages/torch/cuda/__init__.py in current_device()
    349 def current_device():
    350     r"""Returns the index of a currently selected device."""
--> 351     _lazy_init()
    352     return torch._C._cuda_getDevice()
    353 

~/.conda/envs/tensorflow/lib/python3.6/site-packages/torch/cuda/__init__.py in _lazy_init()
    161             "Cannot re-initialize CUDA in forked subprocess. " + msg)
    162     _check_driver()
--> 163     torch._C._cuda_init()
    164     _cudart = _load_cudart()
    165     _cudart.cudaGetErrorName.restype = ctypes.c_char_p

RuntimeError: cuda runtime error (30) : unknown error at /opt/conda/conda-bld/pytorch_1556653099582/work/aten/src/THC/THCGeneral.cpp:51

在互联网上看起来好像是一个版本问题,但是我发誓我尝试了CUDA 10.0、10.1,tensorflow-gpu 13、12等驱动程序的所有组合,并且似乎没有任何作用。

NVIDIA驱动程序:nvidia-smi

    +-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.14       Driver Version: 430.14       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce 930MX       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   36C    P8    N/A /  N/A |    139MiB /  2004MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0       986      G   /usr/lib/xorg/Xorg                            64MiB |
|    0      1242      G   /usr/bin/gnome-shell                          72MiB |
+-----------------------------------------------------------------------------+

CUDA版本nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

tensorflow-gpu版本:pip list | grep tensorflow

tensorflow                         1.13.1   
tensorflow-estimator               1.13.0  

pytorch版本pip list | grep torch

pytorch-pretrained-bert            0.6.2    
torch                              1.1.0    
torchvision                        0.3.0   

任何人都可以看到兼容性问题并解释为什么以及如何解决吗?

1 个答案:

答案 0 :(得分:1)

您是否测试了cuda安装?如果没有,您可以使用(需要一段时间):

 $ cd ~/NVIDIA_CUDA-10.0_Samples
 $ make

然后:

$ cd ~/NVIDIA_CUDA-10.0_Samples/bin/x86_64/linux/release
$./deviceQuery

您应该获得“测试通过!”结果。

Source