文章目录 使用清华镜像源安装Pytorch配置清华镜像源安装Pytorch在Linux上使用shell脚本一键安装
配置清华镜像源
我们使用Anaconda环境进行Pytorch的安装
在命令行中依次输入一下命令并执行
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/# 设置搜索时显示通道地址conda config --set show_channel_urls yes 安装Pytorch使用清华镜像源进行Pytorch的安装时,官方给出的安装命令就失效了
官方给出的安装命令是:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch如果使用清华镜像源安装Pytorch时,需要输入以下命令:
conda install pytorch torchvision cudatoolkit=10.1 在Linux上使用shell脚本一键安装使用Linux系统的时候,有时一步一步复制粘贴命令非常麻烦,特别是使用远程服务器的时候。这时候就需要shell脚本一键解决复制粘贴命令的麻烦。
在任意文件目录下新建一个shell脚本文件,这里取名为 pytorch_install.sh
shell脚本文件的内容如下所示
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/# 设置搜索时显示通道地址conda config --set show_channel_urls yes# 安装pytorchconda install pytorch torchvision cudatoolkit=10.1在命令行中执行shell脚本,输入命令:
bash pytorch_install.sh等待安装完成即可。