使用清华镜像源安装Pytorch

使用清华镜像源安装Pytorch


配置清华镜像源

我们使用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

# 安装pytorch
conda install pytorch torchvision cudatoolkit=10.1

在命令行中执行shell脚本,输入命令:

bash pytorch_install.sh

等待安装完成即可。

  • 17
    点赞
  • 138
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值