#确认电脑版本
win+r 内核版本在20145以上,如果不是,打开设置-预览体验计划,选择dev渠道,升级电脑
store里面下载ubuntu,初始化后应该得到的是18.04版本
确保WSL2的linux内核为4.19.121+
文中crazycat都替换为自己的用户名
#换源
sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get upgrade
如果报错,更换dns
sudo vi /etc/resolv.conf
添加
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
#这里用的是阿里云的DNS服务器
nameserver 223.5.5.5
nameserver 223.6.6.6
#安装一些相关的库
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo apt install build-essential
#安装cuda
sudo sh cuda_10.0.130_410.48_linux.run
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: n
Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
default is /usr/local/cuda-10.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /home/crazycat ]:
sudo vim ~/.bashrc
末尾添加
export PATH="/usr/local/cuda-10.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib:$LD_LIBRARY_PATH"
source ~/.bashrc
#检查cuda
nvcc -V
#安装cudnn
tar -zxvf cudnn-10.0-linux-x64-v7.6.5.32.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
#检查cudnn
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#链接应该能解决大部分问题
https://blog.csdn.net/qq_20291997/article/details/106897324
https://zhuanlan.zhihu.com/p/149848405?from_voters_page=true
https://www.it610.com/article/1295750913624973312.html
https://developer.nvidia.com/blog/announcing-cuda-on-windows-subsystem-for-linux-2/
https://blog.csdn.net/woshiheweigui/article/details/109067091
#安装anaconda3
sudo sh Anaconda3-2020.07-Linux-x86_64.sh
sudo vim ~/.bashrc
#更换pip源
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
#如果make darknet报错cannot find -lcuda
查看路径/usr/local/cuda/lib64下是否存在libcuda.so文件。如果不存在,查看路径/usr/local/cuda/lib64/下是否存在文件夹stubs,打开文件夹,把其中的libcuda.so文件复制到/usr/local/cuda/lib64/目录下
cd /usr/local/cuda/lib64/stubs
sudo cp libcuda.so /usr/local/cuda/lib64/
#报错libcudart.so.10.0: cannot open shared object file: No such file or directory
sudo cp /usr/local/cuda-10.0/lib64/libcudart.so.10.0 /usr/local/lib/libcudart.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcublas.so.10.0 /usr/local/lib/libcublas.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcurand.so.10.0 /usr/local/lib/libcurand.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda/lib64/libcudnn.so.7 /usr/local/lib/libcudnn.so.7 && sudo ldconfig
手把手在wsl上安装cuda
最新推荐文章于 2025-02-22 18:42:58 发布