1 设置为清华源
首先登录wsl 直接命令 wsl 就行
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
sudo sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
2 安装cuda for wsl2
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
sudo sh -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
sudo apt-get update
sudo apt-get install -y cuda-toolkit-11-7
安装mini conda
安装完毕记得重新启动wsl
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,一路回车会失败。安装完毕创建pytorch的一个环境
conda create --name torch python=3.9
conda env list
conda activate torch
安装pytorch
pytorch的官网登录,安装pytorch
https://pytorch.org/get-started/locally/
安装完毕测试
依次输入命令:
conda activate pytorch
python
import torch
torch。
安装桌面
sudo apt update
sudo apt upgrade
sudo apt install -y ubuntu-desktop
sudo apt install -y xrdp
sudo systemctl status xrdp
sudo adduser xrdp ssl-cert
修改端口,防止冲突
sudo sed -i ‘s/port=3389/port=3390/g’ /etc/xrdp/xrdp.ini
防火墙3390端口放开
sudo ufw allow 3390
启动xrdp协议
sudo systemctl restart xrdp