可参考另一篇博客:

自定义WSL的安装位置,别再装到C盘啦 - 知乎

旧版 WSL 的手动安装步骤 | Microsoft Learn

最后设置root账户方法参考:

install_path\ubuntu.exe config --default-user root

在线安装:

Windows 10系统直接安装WSL2-Ubuntu18.04 - 知乎

安装 WSL | Microsoft Docs

ubuntu WSL无法联网问题解决:

设置/etc/resolv.conf配置nameser 8.8.8.8

GPU acceleration in WSL | Microsoft Docs

CUDA on WSL :: CUDA Toolkit Documentation

20200601:

安装wsl 2.0:

安装 WSL | Microsoft Docs

旧版 WSL 的手动安装步骤 | Microsoft Docs

需要安装 更新 WSL 2 Linux 内核旧版 WSL 的手动安装步骤 | Microsoft Docs

这里会下载个文件wsl_update_x64.msi

遇到的一个错误的解决:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x800701bc
Error: 0x800701bc WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel

右键单击wsl_update_x64.msi选择卸载,卸载之前安装的版本后重装解决了。

卸载系统

wsl --unregister Ubuntu-22.04

WSL2.0 安装docker

2020系统综合实践1 WSL 2的安装和基本使用 - zaqny - 博客园

-----------------------------------------------------------------------------

从app store搜索下载linux子系统需要登录,并且下载极其缓慢。不适用app store的安装方法,网上给出的方法实在太复杂。但微软官方其实就提供了极其简单的方法:

Manually download Windows Subsystem for Linux distro packages

Manual installation steps for older versions of WSL | Microsoft Docs

之前可能需要在启用或关闭Windows功能(复制这句话搜索即可)里面勾选适用于Linux的Windows子系统。

Downloading distros

If the Microsoft Store app is not available, you can download and manually install Linux distros by clicking these links:

This will cause the <distro>.appx packages to download to a folder of your choosing. Follow the installation instructions to install your downloaded distro(s).

Installing your distro

If you're using Windows 10 you can install your distro with PowerShell. Simply navigate to folder containing the distro downloaded from above, and in that directory run the following command where app_name is the name of your distro .appx file.

PowershellCopy

Add-AppxPackage .\app_name.appx
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

If you are using Windows server you can find the install instructions on the Windows Server documentation page.

Once your distro is installed please refer to the Intilization Steps page to initialize your new distro.

设置子系统默认登录用户

Windows SubSystem for Linux(WSL)设置默认和设置默认登陆用户 - 余生以学 - 博客园

win10 linux子系统设置默认用户_iJiabao-巨鹿网络的博客-CSDN博客_wsl 设置默认用户

Windows访问WSL2子系统的文件夹:

在文件资源管理器输入

\\wsl$

wsl设置root账户

powershell执行命令(根据版本选择不同选项):

ubuntu config --default-user root # default ubuntu
ubuntu1804 config --default-user root
ubuntu2004 config --default-user root

如果上面找不到命令,也可以直接找到相应的exe文件设置:例如

E:\ProgramData\Ubuntu-WSL2\ubuntu.exe config --default-user root

wsl2可以正常使用nvprof的配套版本:

516.59-desktop-win10-win11-64bit-international-dch-whql.exe

cuda_11.6.1_510.47.03_linux.run

修改wsl占用的内存和CPU资源

how to increase memory and cpu limits for wsl2 windows 11 - Microsoft Q&A

First ensure that the .wslconfig file is defined in the Users folder e.g. C:/Users/yyurijj/.wslconfig
 

[wsl2]
#Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=4GB
#Sets the VM to use two virtual processors
processors=4
  1. Save the file
  2. Run the command "wsl --shutdown" to stop the wsl service
  3. Run the command "restart-service LxssManager" in PowerShell running as administrator to restart wsl
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐