Anaconda安装Pytorch-GPU

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


1. 创建pytorch环境

(1)打开Anaconda Prompt
Anaconda安装Pytorch-GPU_第2张图片
(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官网找到你要下载的版本:
Anaconda安装Pytorch-GPU_第3张图片
将最下方的的代码复制

(2)检测是否安装成功

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

3.出现的问题

(1)虽然添加了镜像,速度有时候还是会出问题,你就多试几次。
(2)如果出现这问题,你得把对应的文件删掉
Anaconda安装Pytorch-GPU_第4张图片

你可能感兴趣的:(pytorch,Python,pytorch,深度学习,python)