-
参考 Enable NVIDIA CUDA on WSL
-
在WSL里的Ubuntu 22.04中进行以下操作前,请先在 Windows 10 中安装好 Nvidia驱动程序 和 CUDA Toolkit 11.7 ,并将 cuDNN 下载后的文件复制到对应目录中
-
安装 Conda 23.5.2
wget https://repo.anaconda.com/archive/Anaconda3-2023.07-1-Linux-x86_64.sh sudo chmod +x ./Anaconda3-2023.07-1-Linux-x86_64.sh sudo ./Anaconda3-2023.07-1-Linux-x86_64.sh # yes # yes tee -a ~/.condarc << EOF channels: - defaults show_channel_urls: true default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ EOF conda clean -i # Python 3.10.12 conda create -n ai python=3.10 conda activate ai python3 -c "import platform; print(platform.architecture()[0]); print(platform.machine())"
-
安装 CUDA 11.7
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run sudo chmod +x ./cuda_11.7.0_515.43.04_linux.run sudo ./cuda_11.7.0_515.43.04_linux.run # accept cd /usr/lib/wsl sudo mkdir lib2 cd lib2 sudo ln -s ../lib/* . cd /usr/local/cuda-11.7/targets/x86_64-linux sudo mkdir lib2 cd lib2 sudo ln -s ../lib/* . sudo tee /etc/ld.so.conf.d/cuda-11-7.conf << EOF /usr/local/cuda-11.7/targets/x86_64-linux/lib2 EOF sudo tee /etc/wsl.conf << EOF [boot] systemd=true command="date '+%Y-%m-%d %H:%M:%S' >> /data/date.log" [automount] ldconfig = false EOF cd /usr/local/cuda-11.7 sudo ln -s targets/x86_64-linux/lib2 lib64 sudo tee /etc/ld.so.conf << EOF include /etc/ld.so.conf.d/*.conf /usr/local/cuda-11.7/lib64 EOF tee -a ~/.bashrc << EOF export PATH=/usr/local/cuda-11.7/bin:\$PATH export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:\$LD_LIBRARY_PATH EOF export PATH=/usr/local/cuda-11.7/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH sudo ldconfig nvcc -V nvidia-smi
-
复制 cuDNN 8.9.2 文件
# 访问 https://developer.nvidia.com/rdp/cudnn-archive 登录后下载 cudnn-linux-x86_64-8.9.2.26_cuda11-archive.tar.xz tar xvJf cudnn-linux-x86_64-8.9.2.26_cuda11-archive.tar.xz cd cudnn-linux-x86_64-8.9.2.26_cuda11-archive sudo cp include/cudnn.h /usr/local/cuda/include/ sudo cp lib/libcudnn* /usr/local/cuda/lib64/ sudo chmod a+r /usr/local/cuda/include/cudnn.h sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
-
安装 PyTorch 2.0.1
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia python -c "import torch; print(torch.cuda.is_available())"
-
安装 PaddlePaddle 2.4
conda install paddlepaddle-gpu==2.4.2 cudatoolkit=11.7 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge python -c "import paddle; print(paddle.__file__)" python -c "import paddle; paddle.utils.run_check();"
-
安装 jupyter notebook
conda install -n ai ipykernel --update-deps --force-reinstall
迎访问我的博客 原文 Windows 10 + WSL 2 + Ubuntu 22.04 搭建 AI 环境