https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig
https://www.jianshu.com/p/5f27368ae88e
https://blog.csdn.net/qq_27843785/article/details/126026399
%UserProfile%
vmmem(wsl)占用内存高怎么解决
C:\Users\clqzc
1.安装前配置
CPU启动虚拟机平台(在BIOS中设置)
管理员权限下设置
$ Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
应用商店下载ubuntu系统,其它发行版本亦可
查看wsl版本:wsl --list --verbose
设置wsl默认版本:wsl --set-default-version 2 或者 wsl --set-version <DistributionName>
版本切换:wsl --set-version Ubuntu-20.04 2
2. 卸载
wsl子系统卸载,查看已安装分发系统:wsl --list --all
正在运行的分发版本:wsl --list --running
删除指定的分发版本:wsl --unregister <DistributionName>
3.基础设置
系统安装成功后会提示输入账号和密码,这是su账户的密码,也就是root用户密码
要使用sudo命令还需要设置另外的用户密码:
su
passwd username
修改管理员密码:
sudo passwd root ·
4.软件安装
1.修改下载源
备份:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
查看系统代号:lsb_release -a
bionic表示18.04,focal表示20.04
修改源(eg: ubuntu 20.04,中科大源,其它源自寻搜索):
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
更新
sudo apt-get update -y
sudo apt-get upgrade -y
安装cmake,g++
设置ssh
查看ssh server是否启动:ps -e | grep ssh
安装:sudo apt install openssh-server
添加hostkeys证书:sudo ssh-keygen -A
手动启动:sudo /etc/init.d/ssh start
配置ssh文件:sudo vim /etc/ssh/sshd_config
Port 2222 #端口号(wsl子系统不影响主机的端口)
PermitRootLOgin yes #允许root远程登录
PasswordAuthentication yes #密码验证登录
AllowUsers sky #远程登录是的用户名
5.安装cuda(WSL2可支持cuda)
安装适配版驱动
https://link.zhihu.com/?target=https%3A//developer.nvidia.com/cuda/wsl
英伟达
更新:
sudo apt update
sudo apt install build-essential
安装docker
–安装依赖:sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
–信任Docker GPG公钥:curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
–添加软件库:
amd64架构–sudo add-apt-repository \ “deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) \ stable”
arm架构–echo “deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable” | \ sudo tee /etc/apt/sources.list.d/docker.list
– 安装
–sudo apt-get update sudo apt-get install docker-ce
–测试
–docker -v
安装c++编译环境
sudo apt install build-essential
检查
gcc --version g++ --version gdb ---version