conda使用国内源安装pytorch


1、添加国内源

用记事本打开C:\Users\LZL\.condarc,添加以下内容:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
ssl_verify: true

注:没有此文件就创建一个.condarc,路径中的LZL需要改成你的用户名。

2、查看本机CUDA版本

命令行输入:nvidia-smi。如下图所示,我的CUDA版本是11.2。

 

3、conda安装pytorch

pytorch官网查看安装命令,用国内源一定要去掉后面的-c pytorch,因为这是指定用官方源安装的命令。

Linux直接在命令行,Windows在Anaconda Prompt命令行输入:

conda install pytorch torchvision torchaudio cudatoolkit=10.2

注:cudatoolkit版本,只要不高于本机CUDA版本(11.2)都可安装。

4、安装完毕,查看pytorch版本


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM