WSL,Theano – 在$PATH上未找到nvcc编译器

huangapple go评论74阅读模式
英文:

WSL, Theano - nvcc compiler not found on $PATH

问题

在此问题被标记为重复之前 - 我已经尝试了Stack Overflow和其他一些网站上提供的所有现有解决方案,但都没有起作用。

我在使用Theano时遇到了错误(Python 2.7.18,Theano 0.6.0,WSL2 Ubuntu 22,Geforce RTX 3070 Ti笔记本电脑) - ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again. 我查了一下,看到了很多现有的Stack Overflow答案,但似乎都不起作用。我以各种不同的方式安装了cuda,我真的不知道我在做什么。

我知道我的配置已经过时,但我想尝试在这个配置上使其工作,我知道以前已经成功过。我只是在克隆别人的git存储库并尝试使用他们的确切版本运行它。

$PATH:

/usr/local/cuda/bin:/usr/local/cuda/bin:/home/william/anaconda3/envs/kg/bin:/home/william/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/libnvvp:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2023.2.0:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python310:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python311/Scripts:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python311:/mnt/c/Users/willi/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/willi/miniconda3/Library/bin:/mnt/c/Users/willi/miniconda3/Scripts:/mnt/c/Users/willi/miniconda3:/mnt/c/Program Files/Graphviz/bin:/snap/bin

$LD_LIBRARY_PATH:

/usr/local/cuda/lib64

~/.theanorc:

[global]
floatX = float32
device = gpu0

[cuda]
root = /usr/local/cuda

我在/usr/lib/cuda/usr/lib/nvidia-cuda-toolkit/usr/local/cuda/usr/local/cuda-12/usr/local/cuda-12.2中都有cuda。其中一些只有一些文件在它们的bin目录中,而其他一些有更多文件。

ls /usr/local/cuda/bin显示了很多东西,包括nvcc。
/usr/local/cuda-12/bin/usr/local/cuda-12.2/bin中都有与/usr/local/cuda/bin相同的文件。
/usr/lib/cuda/bin里什么都没有。
/usr/lib/nvidia-vuda-toolkit/bin中有g++和gcc,这些不在上面的cuda安装中,并且也有nvcc。

我还在/usr/bin中安装了nvcc。

我尝试过的一些方法:

  • 重新启动计算机
  • SO链接1 - 没有提供解决方案
  • SO链接2
    • 我修改了我的PATH以添加cuda安装(我尝试了所有包含nvcc文件的目录)。但不起作用。
  • SO链接3
    • 我已将答案中的部分添加到~/.theanorc
  • SO链接4
    • 没有~/.theano/文件夹。我应该创建一个吗?

我在WSL2上运行Ubuntu。在Windows上使用相同的安装,在Python控制台中运行import theano成功导入,没有nvcc错误。

我还注意到的一件奇怪的事情是运行lspci不显示任何nvidia设备。我认为这是问题的红旗,但我不知道如何修复它。我已经尝试重新安装了显卡驱动程序并按照这里的步骤操作。第4步中的示例应用程序可以工作。

使用最新版本的Theano和Python,并降级numpy以使其与之兼容,我得到了错误pygpu.gpuarray.GpuArrayException: b'cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected。尽管我不打算让最新版本工作,但我认为修复这个错误可能有助于解决其他错误。

我该如何修复这个问题?

英文:

Before this question gets marked as a duplicate - I have tried all of the existing solutions available on SO and some other websites, but none of them are working.

I'm getting an error using theano (Python 2.7.18, Theano 0.6.0, WSL2 Ubuntu 22, Geforce RTX 3070 Ti Laptop) - ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again. I looked it up and saw a lot of existing SO answers, but none of them seemed to work. I have cuda installed in so many different ways I don't really know what I'm doing.

I know my configuration is outdated, but I would like to try to make it work on this configuration, and I know it's been done before. I'm just cloning someone's git repository and trying to run it with their exact versions.

$PATH:

/usr/local/cuda/bin:/usr/local/cuda/bin:/home/william/anaconda3/envs/kg/bin:/home/william/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/libnvvp:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2023.2.0:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python310:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python311/Scripts:/mnt/c/Users/willi/AppData/Local/Programs/Python/Python311:/mnt/c/Users/willi/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/willi/miniconda3/Library/bin:/mnt/c/Users/willi/miniconda3/Scripts:/mnt/c/Users/willi/miniconda3:/mnt/c/Program Files/Graphviz/bin:/snap/bin

$LD_LIBRARY_PATH:

/usr/local/cuda/lib64

~/.theanorc:

[global]
floatX = float32
device = gpu0

[cuda]
root = /usr/local/cuda

I somehow have cuda in /usr/lib/cuda, /usr/lib/nvidia-cuda-toolkit, /usr/local/cuda, /usr/local/cuda-12, and /usr/local/cuda-12.2. Some of them only have a few files in their bin, and some of them have a lot more.

ls /usr/local/cuda/bin shows a lot of stuff, including nvcc.
/usr/local/cuda-12/bin and /usr/local/cuda-12.2/bin all have the same files as /usr/local/cuda/bin.
/usr/lib/cuda/bin has nothing in it.
/usr/lib/nvidia-vuda-toolkit/bin has g++ and gcc, which aren't in the above cuda installations, and has nvcc as well.

I also have an nvcc installation in /usr/bin.

List of stuff I tried:

  • restarting computer
  • SO Link 1 - no solution provided
  • SO Link 2
    • I modified my PATH to add the cuda installation (I've tried all of the directories above where I have an nvcc file). It doesn't work.
  • SO Link 3
    • I have added the section from the answer to ~/.theanorc.
  • SO Link 4
    • No ~/.theano/ folder. Should I make one?

I am on WSL2 running Ubuntu. Using the same installation on Windows, running import theano in a Python console imports successfully with no nvcc error.

One other thing I noticed which is weird is that running lspci doesn't show any nvidia devices. This is what I think is a red flag for the problem but I have no idea how to fix it. I have tried reinstalling my gpu drivers and the steps here. The sample application in step 4 works.

Using the latest version of Theano and Python, and downgrading numpy to work with it, I get the error pygpu.gpuarray.GpuArrayException: b'cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected. Although I'm not trying to get the most recent version working, I think fixing this error might help with the other one.

How can I fix this?

答案1

得分: 0

我最终将“gpu0”在~/.theanorc中更改为“cuda0”,我认为这会对GPU使用另一后端产生某种影响。

英文:

I ended up changing "gpu0" in ~/.theanorc to "cuda0," which I think this does something to the effect of using another backend for the gpu.

huangapple
  • 本文由 发表于 2023年7月20日 12:42:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76726719.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定