❗建议直接Windows安装驱动,不要在子系统里装
-
官网安装,选择自己的版本即可
wget <https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin> sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget <https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-ubuntu2204-12-2-local_12.2.0-535.54.03-1_amd64.deb> sudo dpkg -i cuda-repo-ubuntu2204-12-2-local_12.2.0-535.54.03-1_amd64.deb sudo cp /var/cuda-repo-ubuntu2204-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get updatesudo apt-get -y install cuda
-
查看nvcc发现没有,但
/usr/local/cuda/bin
下是有nvcc的root@DESKTOP-PO8BKKM:~# nvcc --version Command 'nvcc' not found, but can be installed with: apt install nvidia-cuda-toolkit
所以需要添加一下环境变量,就可以了。
root@DESKTOP-PO8BKKM:~# export PATH=$PATH:/usr/local/cuda/bin root@DESKTOP-PO8BKKM:~# nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Tue_Jun_13_19:16:58_PDT_2023 Cuda compilation tools, release 12.2, V12.2.91 Build cuda_12.2.r12.2/compiler.32965470_0
-
nvidia-smi报错
root@DESKTOP-PO8BKKM:~# nvidia-smi NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
按这个:https://blog.csdn.net/weixin_44124632/article/details/130471902
没有解决。。
看一下nvidia版本
root@DESKTOP-PO8BKKM:~# ls /usr/src | grep nvidia nvidia-535.54.03
root@DESKTOP-PO8BKKM:~# sudo apt-get install dkms Reading package lists... Done Building dependency tree... Done Reading state information... Done dkms is already the newest version (2.8.7-2ubuntu2.2). dkms set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 60 not upgraded.
root@DESKTOP-PO8BKKM:~# sudo dkms install -m nvidia -v 535.54.03 Error! Your kernel headers for kernel 5.10.16.3-microsoft-standard-WSL2 cannot be found. Please install the linux-headers-5.10.16.3-microsoft-standard-WSL2 package or use the --kernelsourcedir option to tell DKMS where it's located.
-
卸载试试看
参考:http://www.manongjc.com/detail/62-afswonvqlgmvots.html
sudo apt-get purge nvidia* sudo apt-get autoremove sudo apt-get autoclean sudo rm -rf /usr/local/cuda*
-
尝试重新装一个wls-ubuntu版本cuda
wget <https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin> sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget <https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb> sudo dpkg -i cuda-repo-wsl-ubuntu-12-2-local_12.2.0-1_amd64.deb sudo cp /var/cuda-repo-wsl-ubuntu-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get update sudo apt-get -y install cuda
依然没有用,哈哈
-
尝试直接windows安装,成功。。