可使用tmux
具体用法可以参考https://blog.csdn.net/weixin_40248634/article/details/111224910
tmux new -s torch
安装anaconda
sh Anaconda3-2020.07-Linux-x86_64.sh
source .bashrc
添加镜像
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
显示channels
conda config --show # 显示全部
conda config --show channels # 显示添加的
从原来的服务器导出环境,并在新的服务器安装
conda env export > environment.yaml # 从原来服务器中导出
conda env create -f environment.yaml # 自动建立环境并安装
这种方式很直接,装完就可以用了。
创建并激活环境
如果不是采用直接environment.yaml的方法创建环境,则用下面这种方式
conda create -n pytorch
conda activate pytorch
然后可以开始装一些依赖库,如skicit-learn, pytorch(下面会介绍)
查看cuda 版本
nvidia-smi
从右上角可以看到cuda version 为10.1
安装对应cuda版本的pytorch
https://pytorch.org/get-started/previous-versions/
这里使用之前的pytorch版本1.6
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch
对某个包指定源
pip install [package_name] -i https://pypi.tuna.tsinghua.edu.cn/simple
## 例如
pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple