wsl2 安装参考文档:windows 使用wsl2安装linux子体系_windows wsl2 安装linux-CSDN博客
演示安装ubuntu 22
列出可安装的子体系 命令:wsl --list --online
- PS C:\Users\linyu> wsl --list --online
- 以下是可安装的有效分发的列表。
- 使用 'wsl.exe --install <Distro>' 安装。
- NAME FRIENDLY NAME
- Ubuntu Ubuntu
- Debian Debian GNU/Linux
- kali-linux Kali Linux Rolling
- Ubuntu-18.04 Ubuntu 18.04 LTS
- Ubuntu-20.04 Ubuntu 20.04 LTS
- Ubuntu-22.04 Ubuntu 22.04 LTS
- OracleLinux_7_9 Oracle Linux 7.9
- OracleLinux_8_7 Oracle Linux 8.7
- OracleLinux_9_1 Oracle Linux 9.1
- openSUSE-Leap-15.5 openSUSE Leap 15.5
- SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
- SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
- openSUSE-Tumbleweed openSUSE Tumbleweed
复制代码 安装ubuntu 命令:wsl --install -d Ubuntu-22.04
- PS C:\Users\linyu> wsl --install -d Ubuntu-22.04
- 正在安装: Ubuntu 22.04 LTS
- 已安装 Ubuntu 22.04 LTS。
- 正在启动 Ubuntu 22.04 LTS...
- Installing, this may take a few minutes...
- Please create a default UNIX user account. The username does not need to match your Windows username.
- For more information visit: https://aka.ms/wslusers
复制代码
输入账号密码 安装完成
- Enter new UNIX username:
- New password:
- Retype new password:
- passwd: password updated successfully
- Installation successful!
复制代码 安装显卡驱动
两种方法 二选一即可
1. 第一种方法:
参考官网文档: WSL 上的 CUDA (nvidia.com)
或参考文档:http://t.csdnimg.cn/TVjCa
2.利用ubuntu官方源安装
执行nvidia-smi命令检察英伟达显卡信息,如果没有安装驱动会提示安装,开始安装默认源内里的最新版。
- root@DESKTOP-TUR5ISE:~# nvidia-smi
- Command 'nvidia-smi' not found, but can be installed with:
- apt install nvidia-utils-510 # version 510.60.02-0ubuntu1, or
- apt install nvidia-utils-510-server # version 510.47.03-0ubuntu3
- apt install nvidia-utils-390 # version 390.157-0ubuntu0.22.04.2
- apt install nvidia-utils-418-server # version 418.226.00-0ubuntu5~0.22.04.1
- apt install nvidia-utils-450-server # version 450.248.02-0ubuntu0.22.04.1
- apt install nvidia-utils-470 # version 470.223.02-0ubuntu0.22.04.1
- apt install nvidia-utils-470-server # version 470.223.02-0ubuntu0.22.04.1
- apt install nvidia-utils-525 # version 525.147.05-0ubuntu0.22.04.1
- apt install nvidia-utils-525-server # version 525.147.05-0ubuntu0.22.04.1
- apt install nvidia-utils-535 # version 535.129.03-0ubuntu0.22.04.1
- apt install nvidia-utils-535-server # version 535.129.03-0ubuntu0.22.04.1
复制代码 安装命令:apt install nvidia-utils-535
- root@DESKTOP-TUR5ISE:~# apt install nvidia-utils-535
- Reading package lists... Done
- Building dependency tree... Done
- Reading state information... Done
- The following additional packages will be installed:
- libnvidia-compute-535
- Suggested packages:
- nvidia-driver-535
- The following NEW packages will be installed:
- libnvidia-compute-535 nvidia-utils-535
- 0 upgraded, 2 newly installed, 0 to remove and 84 not upgraded.
- Need to get 41.1 MB of archives.
- After this operation, 177 MB of additional disk space will be used.
- Do you want to continue? [Y/n] y
- Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 libnvidia-compute-535 amd64 535.161.07-0ubuntu0.22.04.1 [40.7 MB]
- Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 nvidia-utils-535 amd64 535.161.07-0ubuntu0.22.04.1 [415 kB]
- Fetched 41.1 MB in 10s (4005 kB/s)
- Selecting previously unselected package libnvidia-compute-535:amd64.
- (Reading database ... 24998 files and directories currently installed.)
- Preparing to unpack .../libnvidia-compute-535_535.161.07-0ubuntu0.22.04.1_amd64.deb ...
- Unpacking libnvidia-compute-535:amd64 (535.161.07-0ubuntu0.22.04.1) ...
- Selecting previously unselected package nvidia-utils-535.
- Preparing to unpack .../nvidia-utils-535_535.161.07-0ubuntu0.22.04.1_amd64.deb ...
- Unpacking nvidia-utils-535 (535.161.07-0ubuntu0.22.04.1) ...
- Setting up libnvidia-compute-535:amd64 (535.161.07-0ubuntu0.22.04.1) ...
- Setting up nvidia-utils-535 (535.161.07-0ubuntu0.22.04.1) ...
- Processing triggers for man-db (2.10.2-1) ...
- Processing triggers for libc-bin (2.35-0ubuntu3.4) ...
- /sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
复制代码
再次执行nvidia-smi 命令看是否能看到显卡信息,怎样能看到则安装成功。
- root@DESKTOP-TUR5ISE:~# nvidia-smi
- Mon Mar 25 16:03:14 2024
- +---------------------------------------------------------------------------------------+
- | NVIDIA-SMI 535.161.07 Driver Version: 537.70 CUDA Version: 12.2 |
- |-----------------------------------------+----------------------+----------------------+
- | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
- | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
- | | | MIG M. |
- |=========================================+======================+======================|
- | 0 NVIDIA GeForce RTX 4090 On | 00000000:01:00.0 On | Off |
- | 30% 28C P8 19W / 450W | 1129MiB / 24564MiB | 5% Default |
- | | | N/A |
- +-----------------------------------------+----------------------+----------------------+
- +---------------------------------------------------------------------------------------+
- | Processes: |
- | GPU GI CI PID Type Process name GPU Memory |
- | ID ID Usage |
- |=======================================================================================|
- | No running processes found |
- +---------------------------------------------------------------------------------------+
复制代码 安装显卡cuda驱动
两种方法二选一即可
1.通过ubuntu官方源安装:apt install nvidia-cuda-toolkit
2.通过添加nvidia官方源的方式安装:
参考官网提供安装方法:CUDA Toolkit 12.4 Downloads | NVIDIA Developerhttps://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local
选好后下面会提供安装方法一条一条执行即可
- 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/12.4.0/local_installers/cuda-repo-wsl-ubuntu-12-4-local_12.4.0-1_amd64.deb
- sudo dpkg -i cuda-repo-wsl-ubuntu-12-4-local_12.4.0-1_amd64.deb
- sudo cp /var/cuda-repo-wsl-ubuntu-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
- sudo apt-get update
- sudo apt-get -y install cuda-toolkit-12-4
复制代码 安装过程取决于网速,应该是必要下载4个G左右的文件,如果顺利的话
将看到如下界面,如果有版本大概其他问题请参考官网。
添加环境变量:
编辑vim ~/.bashrc 末了面添加上
- export PATH=/etc/alternatives/cuda-12/bin:$PATH
- export LD_LIBRARY_PATH=/etc/alternatives/cuda-12/lib64:$LD_LIBRARY_PATH
复制代码 source ~/.bashrc 重新加载一下环境变量
执行nvcc -V 能看到版本信息说明安装成功
- root@DESKTOP-TUR5ISE:/etc/alternatives/cuda-12# nvcc -V
- nvcc: NVIDIA (R) Cuda compiler driver
- Copyright (c) 2005-2024 NVIDIA Corporation
- Built on Tue_Feb_27_16:19:38_PST_2024
- Cuda compilation tools, release 12.4, V12.4.99
- Build cuda_12.4.r12.4/compiler.33961263_0
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |