pytorch学习:Windows-清华源+anaconda安装pytorch

#拒绝套娃,仅作记录#

1.安装cuda,选择适合自己电脑的版本,参考https://blog.csdn.net/u010618587/article/details/82940528

2.安装anaconda,因为之前已经安装过,不再赘述,可从清华镜像中下载,网址为https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

3.搜索并打开anaconda prompt(或者win+R打开窗口输入cmd打开命令行),依次输入命令(不确定是否有多余安装)

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
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/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/(这个命令不太理解什么意思,参照https://blog.csdn.net/WannaSeaU/article/details/88427010?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task   https://blog.csdn.net/qq_35608277/article/details/78714401)

最后输入

conda install pytorch torchvision cudatoolkit=9.0  ##9.0需要替换为安装cuda的对应版本

4.遇到问题

ERROR conda.core.link:_execute_actions(337): An error occurred while installing package ''defaults::tqdm-4.32.1-py_0'.
CondaError: Cannot link a source that does not exist. 

解决方案:输入命令conda install tqdm -f

!!conda clean --all无用

参考https://blog.csdn.net/Purplekate/article/details/99441916的评论

5.测试是否安装完成,参照https://blog.csdn.net/songyuc/article/details/100752884?utm_source=distribute.pc_relevant.none-task

打开anaconda prompt,输入python进入环境

import torch 

import torchvision

print(torch.cuda.is_available())

输出结果如下则安装成功

>>> import torch
>>> import torchvision
>>> print(torch.cuda.is_available())
True
>>>

你可能感兴趣的:(pytorch学习)