赞
踩
驱动下载地址:https://developer.nvidia.com/cuda/wsl 选好你自己的显卡类型
下载完成后直接默认安装就行
如果要卸载以前版本
wsl --list
wsl --unregister Ubuntu-18.04
打开微软商店搜索ubuntu18,或ubuntu20,我安装的是20.04.5,直接下载就行,会自动安装,大概200M
在你的开始菜单里面找到刚刚安装的ubuntu18,单击打开,有可能会遇到以下错误:
错误1:
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
解决办法:
先查看bios的cpu下的虚拟机是否打开。按F2或DEL进入bios,高级模式
PowerShell管理员,输入完重启
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
错误2:
WslRegisterDistribution failed with error: 0x800701bc
解决办法:
下载最新的wsl安装包,直接运行安装即可:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi,安装完重启
错误3:
Installing, this may take a few minutes...
Installation Failed!
Error: 0x8007019e
Press any key to continue...
解决办法:
未安装windows子系统支持
管理员身份打开powershell
输入:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
回车,输入Y,重启
再次打开ubuntu18,换源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo chmod 777 /etc/apt/sources.list
sudo vim /etc/apt/sources.list
在vim的命令模式下键盘上下左右换位置,一直按↓或→
按 i 变成编辑模式,把下面内容复制粘贴进去,右键点一下粘贴
先按ESC退回到命令模式,按 :wq 进行保存,若误操作,则:q! 强制退出不保存
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
更新一下包
sudo apt update
sudo apt upgrade
参考链接https://blog.csdn.net/xautzxc/article/details/107610353
我的显卡是rtx3060,还是安装的cuda11.1,下载的gcc版本是9.4
首先进入cuda官网https://developer.nvidia.com/cuda-toolkit-archive
我选的是11.1.0版本
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/11.1.0/local_installers/cuda-repo-wsl-ubuntu-11-1-local_11.1.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-1-local_11.1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-1-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
添加环境
输入
vi ~/.bashrc
按i键开始插入内容
按↓键滑到文末,复制以下内容
export PATH=$PATH:/usr/local/cuda/bin
再按esc键
输入:wq即可保存退出。
测试是否成功
nvcc -V
进入官网https://developer.nvidia.com/rdp/cudnn-archive
我选择的是8.5.0
![在这里插入图片描述](https://img-blog.csdnimg.cn/52cc69636a1c4c1e91fee9c3e6cfcc98.png
解压
xz -d ***.tar.xz
tar -xvf ***.tar
将解压后的文件改名为cuda
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*
最后测试
···
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
···
一行一行输入
# 切换到用户目录
cd ~
# 下载miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 修改运行权限
chmod 777 Miniconda3-latest-Linux-x86_64.sh
# 运行安装脚本
./Miniconda3-latest-Linux-x86_64.sh
一直按回车,在需要输入yes的时候输入yes
添加环境变量
vim ~/.bashrc
export PATH=/home/alex_ty/miniconda3/bin:$PATH
关闭WSL重新打开就能看见base环境
conda换源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
conda config --set show_channel_urls yes
pip换源
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
创建环境
conda create --name p8t19 python=3.8
激活环境
conda activate p8t19
安装
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
python
import torch
torch.cuda.is_available()
返回True即搭建成功匹配
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。