前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Windows+Anaconda3+PyTorch+PyCharm的安装教程图文详解

Windows+Anaconda3+PyTorch+PyCharm的安装教程图文详解

作者头像
砸漏
发布2020-10-27 15:21:14
4.2K1
发布2020-10-27 15:21:14
举报
文章被收录于专栏:恩蓝脚本恩蓝脚本

1. 安装Anaconda3

官网下载Anaconda3:https://www.anaconda.com/distribution/

在这里插入图片描述
在这里插入图片描述

运行下载好的.exe文件

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Win+R 调出运行对话框,输入 cmd 回车,输入 python,如果出现python版本信息,表明安装成功。

在这里插入图片描述
在这里插入图片描述

添加环境变量:高级系统设置 – 环境变量

在这里插入图片描述
在这里插入图片描述

2. 查看电脑显卡信息

以 Win10 为例,控制面板 – NVIDIA控制面板 – 帮助 – 系统信息 – 组件

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3. 创建PyTorch环境

卸载原来的pytorch和torchvision,之前没有安装则忽略这一步。 Win+R,输入cmdpip uninstall torch,结束后再输入pip uninstall torchvision

打开Anaconda Prompt:

创建PyTorch环境

conda create -n pytorch python=3.6

激活PyTorch环境

activate pytorch

退出:deactivate pytorch

在这里插入图片描述
在这里插入图片描述

4. PyTorch安装

官网下载PyTorch:https://pytorch.org/

p.s. 注意对照版本:)

在这里插入图片描述
在这里插入图片描述

在Anaconda Prompt中激活PyTorch环境

activate pytorch

安装PyTorch

pip install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html

如果安装太慢,可以现在「 源网站 」中下载好,用pip安装 上述版本的下载链接如下:

https://download.pytorch.org/whl/cu92/torch-1.4.0%2Bcu92-cp36-cp36m-win_amd64.whl

https://download.pytorch.org/whl/cu92/torchvision-0.5.0%2Bcu92-cp36-cp36m-win_amd64.whl

pip install (路径)/torch-1.4.0+cu92-cp36-cp36m-win_amd64.whl pip install (路径)/torchvision-0.5.0+cu92-cp36-cp36m-win_amd64.whl

5. 验证安装成功

python import torch import torchvision

均未报错 ,则说明安装成功。

在这里插入图片描述
在这里插入图片描述

6. PyCharm中配置PyTorch

新建一个PyCharm工程,然后File – Settings – Project Interpreter, 这时会发现项目解释器是PyCharm自带的或者是Anaconda自带的python.exe。然而,我们需要使用pytorch的库,所以点击右边代表设置符号,点击add, 选中Existing environment,找到目录并选中:D:\Anaconda\envs\pytorch\python.exe 作为该项目的解释器。

在这里插入图片描述
在这里插入图片描述

验证Pytorch是否导入Pycharm环节,输入:

from future import print_function import torch x = torch.rand(5, 3) print(x)

点击运行没报错就说明可以了

验证Pytorch是否可以使用GPU和CUDA

import torch torch.cuda.is_available()

点击运行没报错,输出 True 就说明配置成功了。

总结

到此这篇关于Windows+Anaconda3+PyTorch+PyCharm的安装教程图文详解的文章就介绍到这了,更多相关Windows Anaconda3 PyTorch PyCharm内容请搜索ZaLou.Cn以前的文章或继续浏览下面的相关文章希望大家以后多多支持ZaLou.Cn!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-09-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. 安装Anaconda3
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档