Ananconda下安装pytorch(GPU),亲测成功(清华源镜像快速下载)
安装了一上午终于成功了!
创建Pytorch虚拟环境
打开Anaconda Prompt,输入下列命令:
conda create -n pytorch python=3.8
启用创建的环境:
conda activate pytorch
点击此链接https://pytorch.org/get-started/locally/,进入pytorch官网,根据自己的配置,生成对应的pytorch下载指令。
选择下载的方式,由于conda要配置源,对萌新不太友好,所以我们选择pip。
直接Run this command会很慢(前期我直接运行了好几次,以失败告终 哭泣泣~~~),我们只需要切换到国内源,就会体验飞一般的感觉!
-i https://pypi.tuna.tsinghua.edu.cn/simple some-package
最后我们运行的命令为:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
输出结果为True,就是成功了!!!
当然,我们安装其他库是也可以使用这个命令进行快速下载!!!
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple
如果这个不成功,就再试试这个!
pip install 包名 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
把xxx,替换成我们需要的库名就好啦!