赞
踩
打开控制面板—>程序与功能—>启用或关闭Windows功能,勾选以下功能
重启
驱动下载地址:https://developer.nvidia.com/cuda/wsl
根据你自己显卡型号选择对应驱动
下载并安装
到应用商店安装WSL,我这里选择Ubuntu-18.04进行安装
WSL安装完成后查看WSL版本
wsl -l -v
如果是WSL1,需要升级到WSL2
下载Linux 内核更新包并安装,下载地址
将Ubuntu18.04 设置为WSL2
wsl --set-version Ubuntu-18.04 2
查看wsl版本,看是否变成版本2
wsl -l -v
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo sh -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
sudo apt-get update
sudo apt-get install -y cuda-toolkit-11-0
如果缺少依赖报错就安装下面依赖,安装前记得先按下面步骤换源,否则下载速度贼慢
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
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命令模式下按d,删除里面内容
按i切换到编辑模式 将下面内容粘贴进去
按esc按键回到命令模式 按:wq保存文件
阿里源:
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
# 切换到家目录
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
conda init
创建环境
conda create --name torch python=3.8
激活环境
conda activate torch
安装pytorch,Pytorch官网地址
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
验证cuda环境
conda activate torch
python
import torch
torch.cuda.is_available()
恭喜你,环境搭建成功
WSL2可以直接使用图形界面打开软件,使用VScode打开当前目录
code .
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。