pytorch+Anaconda+python3.10+parcharm+win10安装简化教程

Pytorch+Anaconda+Python3.10+parcharm+WIN10安装简化教程

pycharm的安装

1、首先登陆pycharm官网,https://www.jetbrains.com/pycharm/download/
2、下载community版本
在这里插入图片描述
3、下载完成后,双击安装,一直点下一步。
在这里插入图片描述

Anaconda的安装

1、首先登录anaconda官网,https://www.anaconda.com/
2、点击Download下载安装包
在这里插入图片描述
3、双击安装包安装,选择Just Me
4、更换路径,不是C盘就行
5、勾选两个选项框,安装。
在这里插入图片描述
在这里插入图片描述
6、wait a minute,安装完成。

Python的安装

1、输入网址python.org,点击downloads,all releases,然后点击windows,最后选择3.10.10版本,64位。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、双击exe文件进行安装,勾选这两个选项;然后安装;
在这里插入图片描述

Pytorch的安装

1、在开始菜单中找到Anaconda Prompt,右键管理员打开(这里必须要管理员)
2、默认进入base环境
在这里插入图片描述
3、修改清华源下载路径

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
conda config --set show_channel_urls yes
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64

4、创建pytorch虚拟环境,在base环境下,输入以下代码;(pytorch为环境名)

conda activate pytorch

5、不关闭Anaconda Prompt,打开浏览器打开网址https://pytorch.org/get-started/previous-versions/;选择需要的torch版本;比如说你的cuda版本为11.3,你选择11.3对应的pytorch版本;但是注意粘贴到的网站需要删除掉-c pytorch;
在这里插入图片描述

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3

6、将复制的指令放入刚才未关闭的Anaconda Prompt中,等待安装成功;(途中需要输入“y”来继续安装)

7、不要关闭Anaconda Prompt界面,分别输入以下指令

conda --version
activate
python

在这里插入图片描述
不报错为安装成功;

parcharm环境配置

1、在python、Anaconda、pytorch、parcharm安装完毕后,需要打开parcharm配置环境;
2、点击左上角File,New Project;
在这里插入图片描述

3、自定义项目位置Location,然后选择Previously configured interpreter,点击Add Interpereter,点击Add Local Interpreter
在这里插入图片描述

在这里插入图片描述
4、选择conda Environment,选择anaconda3安装路径下的Scripts文件夹下的conda.exe文件;然后点击Load Environments;
选择Use existing environment,选择以下环境;点击OK(注:因为我们没有创建虚拟环境,所以环境在这个路径下)
在这里插入图片描述

5、配置完成后,点击File,Settings,Project:…,python Interpreter,确认里面的pytorch安装包,到此安装完成
在这里插入图片描述
6、验证环境配置是否正确,在parcharm中输入以下代码。运行后出现以下内容即为环境配置完成。

import torch
import numpy as np
arr=np.ones((3,3))
print("arr的数据类型为:"+str(arr.dtype))
t=torch.tensor(arr)
print(t)

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

*#*安装好的小伙伴们,记得一键三连哦!!!谢谢

猜你喜欢

转载自blog.csdn.net/WDX4092410/article/details/129496575