WSL2 构建Ubuntu系统-轻量级AI运行环境

ops/2024/10/22 11:38:30/

环境:Win11

软件:WSL2

安装环境:Ubuntu 22.04

检查电脑是否开启虚拟化

打开:任务管理器->性能->CPU 

CPU 开启虚拟化(通常默认是开启的,如果没有开启需要BIOS开启)

图片

虚拟化设置,打开:控制面板->程序->启动或关闭Windows功能

图片

WSL2 安装 Ubuntu24.04

以管理员的身份运行 cmd

step1、更新 WSL2

## step1、更新 WSL2
C:\Users\> wsl --update  --web-download
正在下载: 适用于 Linux 的 Windows 子系统
正在安装: 适用于 Linux 的 Windows 子系统
已安装 适用于 Linux 的 Windows 子系统。

step2、查看支持安装的Linux系统

# 查看 支持安装的Linux 系统
C:\Users\> wsl --list -o
以下是可安装的有效分发的列表。
使默认分发用 “*” 表示。
使用 'wsl --install -d Ubuntu-24.04' 安装。NAME                            FRIENDLY NAME
* Ubuntu                          UbuntuDebian                          Debian GNU/Linuxkali-linux                      Kali Linux RollingUbuntu-18.04                    Ubuntu 18.04 LTSUbuntu-20.04                    Ubuntu 20.04 LTSUbuntu-22.04                    Ubuntu 22.04 LTSUbuntu-24.04                    Ubuntu 24.04 LTSOracleLinux_7_9                 Oracle Linux 7.9OracleLinux_8_7                 Oracle Linux 8.7OracleLinux_9_1                 Oracle Linux 9.1openSUSE-Leap-15.6              openSUSE Leap 15.6SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6openSUSE-Tumbleweed             openSUSE Tumbleweed

step3、安装 Ubuntu 24.04

# 安装 Ubuntu24.04(安装过程中需要设置Ubuntu用户名和密码)
C:\Users>wsl --install -d Ubuntu-24.04 --web-download
正在下载: Ubuntu 24.04 LTS
正在安装: Ubuntu 24.04 LTS
已安装 Ubuntu 24.04 LTS。
正在启动 Ubuntu 24.04 LTS...
Installing, this may take a few minutes...Welcome to Ubuntu 24.04 LTS (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/proSystem information as of Mon Oct 21 10:01:19 CST 2024System load:  0.0                 Processes:             47Usage of /:   0.1% of 1006.85GB   Users logged in:       0Memory usage: 3%                  IPv4 address for eth0: 172.27.50.209Swap usage:   0%This message is shown once a day. To disable it please create the
/home/keyboardman/.hushlogin file.

Ubuntu24.04 基础环境配置

step1、更新环境

sudo apt-get update
sudo apt-get upgrade

step2、安装Docker

## 卸载老版本
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done## 设置 Docker 仓库
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc# Add the repository to Apt sources:
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update## 安装最新版本 Docker 
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

step3、Docker NVIDIA 支持安装

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo sed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/nvidia-container-toolkit.list## 安装 NVIDIA 运行时包和依赖项
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit## 配置
sudo nvidia-ctk runtime configure --runtime=docker
## 重启 Docker 
sudo systemctl restart docker

step2、验证 Docker 是否支持GPU运行

sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

打印 GPU 信息,即表示环境搭建成功

图片


http://www.ppmy.cn/ops/127555.html

相关文章

Python GIF压缩工具实现详解:PIL的实践

在本文中,我们将详细分析一个使用Python开发的GIF压缩工具的实现。这个工具结合了wxPython的GUI框架和PIL(Python Imaging Library)的图像处理能力,提供了两种压缩方式:颜色深度压缩和帧数压缩。 C:\pythoncode\new\gifcompress.py 全部代码…

PostgreSQL的学习心得和知识总结(一百五十五)|[performance]优化期间将 WHERE 子句中的 IN VALUES 替换为 ANY

目录结构 注:提前言明 本文借鉴了以下博主、书籍或网站的内容,其列表如下: 1、参考书籍:《PostgreSQL数据库内核分析》 2、参考书籍:《数据库事务处理的艺术:事务管理与并发控制》 3、PostgreSQL数据库仓库…

正则化、交叉验证、

正则化 是机器学习中用来防止模型过拟合的一种技术。过拟合是指模型在训练数据上表现很好,但在新的、未见过的数据上表现不佳。正则化通过在损失函数中添加一个额外的项来实现,这个额外的项通常与模型的复杂度相关。下面是正则化项的作用和意义&#xf…

FPGA实现UDP通信(2)——通信接口简介

1.概述 网口相信对于大家来说并不陌生,无论是笔记本、台式机、还是交换机、路由器,上面都有网口,事实上,从专业的角度名词来说,这些网口都被称为RJ45接口。如下图所示: 但从功能来说,这些网口只是起到一个信号连接的作用,本身无主动通信的能力,一个典型的网络通信电路…

AttributeError: module ‘lib‘ has no attribute ‘OpenSSL_add_all_algorithms‘

问题:AttributeError: module ‘lib’ has no attribute ‘OpenSSL_add_all_algorithms’ 分析 在使用certbot时,报了这个错误,该问题是没有安装openssl包 解决 pip3 install pyOpenSSL 安装后再次运行如果还是报错,请降低加…

css定位属性

CSS的定位属性有三种&#xff0c;分别是绝对定位、相对定位、固定定位。 position: absolute; <!-- 绝对定位 -->position: relative; <!-- 相对定位 -->position: fixed; <!-- 固定定位 -->绝对定位 **绝对定位的盒子脱离了标准文档流。**所以&#x…

分布式ID多种生成方式

分布式ID 雪花算法&#xff08;时间戳41机器编号10自增序列号10&#xff09; 作用&#xff1a;希望ID按照时间进行有序生成 原理&#xff1a; 即一台带有编号的服务器在毫秒级时间戳内生成带有自增序号的ID,这个ID保证了自增性和唯一性 雪花算法根据结构的生成ID个数的上线时…

Docker和K8S的区别

Docker和K8S的区别 Docker和Kubernetes&#xff08;简称K8S&#xff09;是两个在容器化技术领域非常重要的工具&#xff0c;它们各自有着不同的功能和用途。下面是它们之间的主要区别&#xff1a; 容器运行时 vs 容器编排工具&#xff1a; Docker是一个容器运行时&#xff0c;主…