Ubuntu(CentOS、Rockylinux等)快速进入深度学习pytorch环境

这里写自定义目录标题

安装进入系统(如Ubuntu22.04)

docker 、 wsl 、 双系统 、服务器系统

推荐 Ubuntu 20.04:WSL 官方推荐使用 Ubuntu 20.04 或更高版本

安装anaconda

默认安装最新版anaconda

bash 复制代码
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

如果需要指定版本

bash 复制代码
# 进入官网查看需要的系统及其下的版本
https://repo.anaconda.com/miniconda/
# 拼接路径下载
wget https://repo.anaconda.com/miniconda/<FILENAME>

pip、conda换源

pip换源

一步到位:

bash 复制代码
mkdir -p ~/.pip && echo -e "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\n[install]\ntrusted-host=mirrors.aliyun.com" > ~/.pip/pip.conf

或者

bash 复制代码
# 查看pip.conf路径
pip -v config list

# 修改配置文件
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

其他源

bash 复制代码
# 阿里云
http://mirrors.aliyun.com/pypi/simple/
# 豆瓣
http://pypi.douban.com/simple/
# 清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
# 中国科学技术大学
http://pypi.mirrors.ustc.edu.cn/simple

conda换源

一步到位

bash 复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

或者

bash 复制代码
# 查看.condarc路径
conda info

# 修改配置文件
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
show_channel_urls: true
ssl_verify: false

其他源

bash 复制代码
# 阿里
channels:
  - http://mirrors.aliyun.com/anaconda/pkgs/main
  - http://mirrors.aliyun.com/anaconda/pkgs/r
  - http://mirrors.aliyun.com/anaconda/pkgs/msys2
show_channel_urls: true
ssl_verify: false

# 中科大
channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
show_channel_urls: true
ssl_verify: false

安装nvidia

WSL 无需手动安装驱动,宿主机的 NVIDIA 驱动会自动共享给 WSL,只需安装 CUDA

bash 复制代码
# 添加图形驱动源
sudo add-apt-repository ppa:graphics-drivers/ppa

# 更新
sudo apt update && sudo apt upgrade

# 查找可安装的版本
ubuntu-drivers devices

# 选择自己需要的版本
sudo apt install nvidia-driver-xxx
# 举个例子
sudo apt install nvidia-driver-550

# 重启
sudo reboot

# 查看已安装的驱动
nvidia-smi

安装pytorch环境

bash 复制代码
conda create -n yourname python=3.8 -y
# 12.6
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
# 11.8
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

针对于wsl的优化

bash 复制代码
# 1. 开启cpu虚拟化
# 进BIOS

# 2. 启用或关闭 Windows 功能",勾选 "Hyper-V""Windows 虚拟机监控程序平台""适用于 Linux 的 Windows 子系统""虚拟机平台"。

# 3. 管理员身份运行
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux,VirtualMachinePlatform

# 4. 重启

# 5. 确认功能开启
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

# 6. wsl 更新
wsl --update

# 7. 安装发行版本
wsl --list --online
wsl --install -d Ubuntu-20.04
相关推荐
一位摩羯座DBA1 小时前
Redhat&Centos挂载镜像
linux·运维·centos
学习3人组1 小时前
CentOS配置网络
linux·网络·centos
shangyingying_11 小时前
关于小波降噪、小波增强、小波去雾的原理区分
人工智能·深度学习·计算机视觉
书玮嘎2 小时前
【WIP】【VLA&VLM——InternVL系列】
人工智能·深度学习
要努力啊啊啊2 小时前
YOLOv2 正负样本分配机制详解
人工智能·深度学习·yolo·计算机视觉·目标跟踪
Blossom.1183 小时前
机器学习在智能建筑中的应用:能源管理与环境优化
人工智能·python·深度学习·神经网络·机器学习·机器人·sklearn
m0_678693335 小时前
深度学习笔记29-RNN实现阿尔茨海默病诊断(Pytorch)
笔记·rnn·深度学习
胡耀超5 小时前
标签体系设计与管理:从理论基础到智能化实践的综合指南
人工智能·python·深度学习·数据挖掘·大模型·用户画像·语义分析
fzyz1237 小时前
Windows系统下WSL从C盘迁移方案
人工智能·windows·深度学习·wsl
即将头秃的程序媛8 小时前
centos 7.9安装tomcat,并实现开机自启
linux·运维·centos