【问题标题】:CUDA runtime unknown error, maybe a driver problem? CUDA can't see my gpuCUDA 运行时未知错误,可能是驱动程序问题? CUDA 看不到我的 gpu
【发布时间】:2019-05-27 13:56:21
【问题描述】:

我的代码现在很简单:

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   

谁能看到兼容性问题并解释为什么以及如何解决它?

【问题讨论】:

  • 你试过这个github.com/tensorflow/tensorflow/issues/… 吗?或者只是重新启动
  • 您的问题与 tensorflow 有什么关系?您只展示了 PyTorch 的代码。
  • @BramVanroy 你说得对,我还想上传一些 tensorflow 代码,但后来我意识到没有必要。
  • @DSDS 感谢您的回答!我没有尝试,但我放弃了这个问题并使用 Google Colab 切换到云计算,所以我想我会删除这个问题。谢谢大家!

标签: python tensorflow pytorch nvidia


【解决方案1】:

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

 $ cd ~/NVIDIA_CUDA-10.0_Samples
 $ make

然后:

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

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

Source

【讨论】:

  • 感谢您的回答,可能错误是由于安装NVIDIA驱动程序引起的,它还会自动安装CUDA驱动程序,您可以看到它与CUDA-development-kit的版本不同我下载的。在安装过程中,建议不要同时安装 CUDA 驱动程序,所以我这样做了。问题是我无法从 NVIDIA 降级 CUDA 驱动程序,也无法从 CUDA-dk 安装程序安装它们,因为它会引发一些错误(我认为这是可以修复的,但我没有时间)。我使用 Google Colab 而不是我的个人笔记本电脑解决了所有问题啊哈哈哈
猜你喜欢
  • 2010-09-19
  • 1970-01-01
  • 2012-06-07
  • 2016-03-09
  • 1970-01-01
  • 1970-01-01
  • 2017-03-07
  • 2020-03-13
  • 2016-08-14
相关资源
最近更新 更多