Anaconda安装Pytorch-GPU

本文介绍在Anaconda下如何安装Pytorch,首先你得自己安装Anaconda,CUDA,cudnn,安装教程网上有:从第二步开始,下载Anaconda
Pytorch官网找到你要的CUDA版本,确定好CUDA版本才好后续的操作。
在这里插入图片描述


1. 创建pytorch环境

(1)打开Anaconda Prompt
在这里插入图片描述
(2)首先创建pytorch环境
conda create -n pytorch python=3.7
(3)激活环境
conda activate pytorch
(4)添加镜像源
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
conda config --set show_channel_urls yes


2.安装pytorch

(1)在Pytorch官网找到你要下载的版本:
在这里插入图片描述
将最下方的的代码复制

(2)检测是否安装成功

python
import torch
print(torch.__version__)
torch.cuda.is_available()

3.出现的问题

(1)虽然添加了镜像,速度有时候还是会出问题,你就多试几次。
(2)如果出现这问题,你得把对应的文件删掉
在这里插入图片描述


版权声明:本文为SDFJXVC原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。