1. miniconda
下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.9.2-Linux-x86_64.sh --no-check-certificate
安装
bash Miniconda3-py37_4.9.2-Linux-x86_64.sh
创建虚拟环境
conda create -n env_flow python=3.7
查看虚拟环境
conda env list
进入虚拟环境
conda activate env_flow
删除虚拟环境
conda remove -n envname --all
删除环境中的某个包
conda remove --name envname packagename
换源, pytorch安装GPU版本的话,最好不要用国内源,因为清华源有时候会给你下载CPU版本。这里顺便换源了,但后面下载还是用官网。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
2. pytorch + torchvision + torchaudio
先产看cuda版本
nvcc --version
安装对应版本
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
确定安装情况
python
import torch
print(torch.__version__)
#1.9.0+cu111 说明安装成功
print(torch.cuda.is_available())
#True 说明GPU可用