深度学习环境配置指令大全
文章目录
- 环境配置
- 官网/博客合集
- 清华镜像站
- anaconda官网
- pytorch官网
- pytorch历史库
- 官网pytorch与cuda对应版本下载
- 博客torch与torchvision与python对应关系
- python与pytorch对应关系
- 环境相关
- 创建环境
- 激活环境
- 退出环境
- 删除环境
- 检查环境冲突
- 安装相关
- 安装requirements
- conda安装
- conda卸载
- pip安装
- pip卸载
- 镜像源相关
- pip源
- conda源
- 清除源
- 系统或conda相关
- 更新conda环境
- 清除缓存
- pip导出
- pip导入
- conda导出
- conda导入
- 检查与查看相关
- 查看指定包
- 查看现有包
- 查看显卡环境
- 查看cuda版本
- torch是否可用
- cuda是否可用
- TensorFlow是否可用
- 快速安装指令
- 创建环境 python3.9 cu118
环境配置
官网/博客合集
清华镜像站
anaconda官网
pytorch官网
pytorch历史库
官网pytorch与cuda对应版本下载
博客torch与torchvision与python对应关系
python与pytorch对应关系
环境相关
创建环境
conda create --n unet python=3.9
激活环境
conda activate unet
退出环境
conda deactivate
删除环境
conda remove -n unet --all
检查环境冲突
pip check
安装相关
安装requirements
pip install -r requirements.txt
安装时显示进度条
pip install -r requirements.txt --progress-bar on
conda安装
指定版本加=
conda install torch=2.1.0
conda卸载
conda remove torch
pip安装
指定版本加==
pip install torch==2.1.1
如何下载老版本?pip 后面加上这一段
-f https://download.pytorch.org/whl/torch_stable.html
想换清华源
-i https://pypi.tuna.tsinghua.edu.cn/simple
pip卸载
pip uninstall torch
镜像源相关
pip源
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
conda源
conda config --remove-key channels
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
清除源
->恢复默认
conda config --remove-key channels
系统或conda相关
更新conda环境
conda update -all
清除缓存
conda clean --all
pip导出
导出环境为txt
pip freeze > requirements.txt
pip导入
用txt导入环境依赖
pip install -r requirements.txt
conda导出
导出为yml
conda envname export > requirements.yml
conda导入
用yml文件导入环境依赖
conda envname create -f requirements.yml
检查与查看相关
查看指定包
conda search name
查看现有包
conda list
查看显卡环境
nvidia-smi
查看cuda版本
nvcc -V
torch是否可用
python
import torch
#查看cuda是否可用
print(torch.__version__)
#当前torch版本
print(torch.cuda.is_available())
#查看cuda设备的数量
print(torch.cuda.device_count())
#查看当前使用的cuda编号
print(torch.cuda.current_device())
#查看GPU设备名字
print(torch.cuda.get_device_name())
#查看设备容量
print(torch.cuda.get_device_capability(0))
#查看算力
cuda是否可用
nvcc -V
python
print(torch.__version__)
print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.version.cuda)
TensorFlow是否可用
先python进入编辑页面
python
import tensorflow as tf
print("TensorFlow Version:", tf.__version__)
print("Available devices: ", tf.config.experimental.list_physical_devices())
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
快速安装指令
创建环境 python3.9 cu118
conda create -n new python=3.9
conda activate new
conda update --all
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
conda install tensorflow-gpu=2.6
conda install cudatoolkit=11.3
conda install cudnn=8.2
pip install numpy==1.23.4