安装Miniconda
在项目未关闭的情况之下使用,项目会自动重置,所以安装Miniconda进行包管理,这样重启以后就不会被重置
总体过程
下载: wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh
安装: bash Miniconda3-4.7.12.1-Linux-x86_64.sh
激活conda: source ~/miniconda3/bin/activate
更换清华源(下载速度会更好,具体百度)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
配置PyTorch环境
激活conda source ~/miniconda3/bin/activate
创建环境 conda create --name Env_PyTorch python=3.7
进入创建好的环境 conda activate Env_Pytoch 安装PyTorch conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 (去除掉-c pytorch才是使用清华源进行安装的否则仍然是原有的源安装)
配置其他的需要的包 conda install ipython
conda install scikit-image
conda install scipy==1.2.0
conda install tqdm
conda install pillow=6.1
conda install h5py
conda install nltk
验证是否安装PyTorch成功
python >>>import torch >>>print(torch.cuda.is_available()) >>>print(torch.__version__)
注意:每次重启终端都要重新运行(就是每次激活环境)
source ~/work/miniconda3/bin/activate conda activate Env_PyTorch 这是我参考博客,大家可以看看