广告
返回顶部
首页 > 资讯 > 后端开发 > Python >pytorch的安装(非常详细)
  • 555
分享到

pytorch的安装(非常详细)

pytorchpython深度学习 2023-10-21 07:10:01 555人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

文章目录 1.pytorch的安装1.1环境配置1.2创建pytorch文件夹(环境)1.3查看pytorch历史版本1.4接下来有一个小技巧1.4.1清华源:1.4.2中科大源: 1.

文章目录

1.PyTorch的安装

1.1环境配置

在这里插入图片描述

运行这个

在这里插入图片描述
Anaconda安装详细步骤请看我之前写的http://t.csdn.cn/CZtm3

1.2创建pytorch文件夹(环境)

在这里插入图片描述

在这里插入图片描述
然后回车等待着安装

在这里插入图片描述
出现这个就按照成功了
在这里插入图片描述
再看文件夹就多了一个文件pytorch

在这里插入图片描述
然后我们输入命令进入pytorch环境conda activate pytorch

在这里插入图片描述
可以看到我们已经进入了pytorch环境
在这里插入图片描述
这个命令是查看该环境下所安装的包conda list

1.3查看pytorch历史版本

之前版本的链接https://pytorch.org/get-started/previous-versions/

在这里插入图片描述
我选择了这个,因为我的cuda下载的是11.1

1.4接下来有一个小技巧

我们在使用anaconda环境管理软件时,通过指令下载的各种包,其默认的源,也就是提供安装包或压缩包的服务器,是他们公司自己设立的。这个服务器的位置是在国外,因此链接速度慢,不稳定,下载速度也慢。我们可以通过指令将下载源置为国内源。
这里推荐清华源、中科大源。

1.4.1清华源:

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 --set show_channel_urls yes

1.4.2中科大源:

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/conda config --set show_channel_urls yes

将全部指令复制粘贴进命令行即可。换源之后下载速度起飞。

将这些指令复制到Anaconda里面

在这里插入图片描述

完成改下载源。

在这里插入图片描述

查看源有没有添加进去指令是

conda config --show-source

1.5开始下载pytorch环境

在这里插入图片描述
然后回车等待安装
在这里插入图片描述
在这里插入图片描述
这里是下载包的版本

在这里插入图片描述
这里显示的是所需要安装的 大小
在这里插入图片描述
填y回车

在这里插入图片描述
等待安装

在这里插入图片描述

安装成功

在这里插入图片描述
退出pytorch环境

conda deactivate

在这里插入图片描述
查看环境信息

conda info -e

完成

1.6验证pytorch安装成功

在这里插入图片描述
在pytorch环境中输入python,然后import torch,出现我这种情况就说明安装成功了

import torch

在这里插入图片描述
这个是验证cuda是不是可以正常运行

torch.cuda.is_available()

在这里插入图片描述
退出Python环境

quit()

1.7卸载pytorch环境

在这里插入图片描述

这条语句是将pytorch环境删除,根据提示走,我就不演示了,好不容易下载好的环境,就不删了

conda remove -n pytorch --all

1.8将PyCharm的环境换成Anaconda下的pytorch环境

在这里插入图片描述

点击settings

在这里插入图片描述
在这里插入图片描述
详细的看我的博客http://t.csdn.cn/emDn2

在这里插入图片描述

然后点add

在这里插入图片描述

完结

来源地址:https://blog.csdn.net/Redamancy06/article/details/125820669

--结束END--

本文标题: pytorch的安装(非常详细)

本文链接: https://www.lsjlt.com/news/433495.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作