【安装pytorch】

项目场景:

提示:这里简述项目相关背景:

例如:项目需求安装pytorch,安装神经网络环境配置。


问题描述

提示:这里描述项目中遇到的问题:
安装pytorch
官网 https://pytorch.org/ 详细看官方提供的手册
安装时选择cuda11.8的版本(与电脑安装的驱动版本一致,需要提前安装好驱动)
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

C:\Users\14397>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Looking in indexes: https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch in c:\users\14397\appdata\roaming\python\python312\site-packages (2.2.0)
Requirement already satisfied: torchvision in c:\users\14397\appdata\roaming\python\python312\site-packages (0.17.0)
Collecting torchaudioUsing cached https://download.pytorch.org/whl/cu118/torchaudio-2.2.0%2Bcu118-cp312-cp312-win_amd64.whl (3.9 MB)
Requirement already satisfied: filelock in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.13.1)
Requirement already satisfied: typing-extensions>=4.8.0 in c:\python312\lib\site-packages (from torch) (4.9.0)
Requirement already satisfied: sympy in c:\python312\lib\site-packages (from torch) (1.12)
Requirement already satisfied: networkx in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.2.1)
Requirement already satisfied: jinja2 in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.1.3)
Requirement already satisfied: fsspec in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (2024.2.0)
Requirement already satisfied: numpy in c:\python312\lib\site-packages (from torchvision) (1.26.4)
Requirement already satisfied: requests in c:\users\14397\appdata\roaming\python\python312\site-packages (from torchvision) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\python312\lib\site-packages (from torchvision) (10.2.0)
Collecting torchDownloading https://download.pytorch.org/whl/cu118/torch-2.2.0%2Bcu118-cp312-cp312-win_amd64.whl (2704.2 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━ 2.5/2.7 GB 1.6 MB/s eta 0:02:18
ERROR: Exception:
Traceback (most recent call last):File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcheryieldFile "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 561, in readdata = self._fp_read(amt) if not fp_closed else b""^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_readreturn self._fp.read(amt) if amt is not None else self._fp.read()^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in readdata: bytes = self.__fp.read(amt)^^^^^^^^^^^^^^^^^^^File "C:\Python312\Lib\http\client.py", line 472, in reads = self.fp.read(amt)^^^^^^^^^^^^^^^^^File "C:\Python312\Lib\socket.py", line 707, in readintoreturn self._sock.recv_into(b)^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python312\Lib\ssl.py", line 1249, in recv_intoreturn self.read(nbytes, buffer)^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python312\Lib\ssl.py", line 1105, in readreturn self._sslobj.read(len, buffer)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed outDuring handling of the above exception, another exception occurred:Traceback (most recent call last):File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapperstatus = run_func(*args)^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapperreturn func(self, options, args)^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\commands\install.py", line 377, in runrequirement_set = resolver.resolve(^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 95, in resolveresult = self._result = resolver.resolve(^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolvestate = resolution.resolve(requirements, max_rounds=max_rounds)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\resolvers.py", line 427, in resolvefailure_causes = self._attempt_to_pin_criterion(name)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\resolvers.py", line 239, in _attempt_to_pin_criterioncriteria = self._get_updated_criteria(candidate)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\resolvers.py", line 230, in _get_updated_criteriaself._add_to_criteria(criteria, requirement, parent=candidate)File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteriaif not criterion.candidates:^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\resolvelib\structs.py", line 156, in __bool__return bool(self._sequence)^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__return any(self)^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in <genexpr>return (c for c in iterator if id(c) not in self._incompatible_ids)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_builtcandidate = func()^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 182, in _make_candidate_from_linkbase: Optional[BaseCandidate] = self._make_base_candidate_from_link(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 228, in _make_base_candidate_from_linkself._link_candidate_cache[link] = LinkCandidate(^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 290, in __init__super().__init__(File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__self.dist = self._prepare()^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 222, in _preparedist = self._prepare_distribution()^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 301, in _prepare_distributionreturn preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\operations\prepare.py", line 525, in prepare_linked_requirementreturn self._prepare_linked_requirement(req, parallel_builds)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\operations\prepare.py", line 596, in _prepare_linked_requirementlocal_file = unpack_url(^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\operations\prepare.py", line 168, in unpack_urlfile = get_http_url(^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\operations\prepare.py", line 109, in get_http_urlfrom_path, content_type = download(link, temp_dir.path)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\network\download.py", line 147, in __call__for chunk in chunks:File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\cli\progress_bars.py", line 53, in _rich_progress_barfor chunk in iterable:File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_internal\network\utils.py", line 63, in response_chunksfor chunk in response.raw.stream(File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 622, in streamdata = self.read(amt=amt, decode_content=decode_content)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 560, in readwith self._error_catcher():File "C:\Python312\Lib\contextlib.py", line 155, in __exit__self.gen.throw(value)File "C:\Users\14397\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcherraise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.

指令:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

该命令是用来通过pip3(Python的包管理工具)安装PyTorch及其相关库torchvision和torchaudio的。具体来说,这个命令的作用如下:

  1. pip3 install: 使用pip3来安装Python包。pip3是Python 3的包管理工具,用于从Python Package Index(PyPI)或其他源安装Python包。
  2. torch: PyTorch是一个开源的深度学习库,广泛用于各种机器学习和深度学习应用。
  3. torchvision: torchvision是PyTorch的一个扩展库,提供了计算机视觉中常用的数据集、模型、图像转换等功能。
  4. torchaudio: torchaudio是另一个PyTorch的扩展库,专门用于音频处理。
  5. --index-url https://download.pytorch.org/whl/cu118: 这个参数指定了pip3从哪个URL下载这些包。这里,它指定了一个特定的URL,该URL包含了为CUDA 11.8版本编译的PyTorch包。这意味着如果你的机器上安装了NVIDIA的CUDA 11.8版本,并且你有一块支持CUDA的NVIDIA显卡,那么这个命令将下载并安装与CUDA 11.8兼容的PyTorch版本。

总之,这个命令用于安装与CUDA 11.8兼容的PyTorch、torchvision和torchaudio库。这通常用于加速深度学习模型的训练和推理,特别是在具有NVIDIA GPU的计算机上。

原因分析:

提示:这里填写问题的分析:
网络问题:

继续装


C:\Users\14397>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Looking in indexes: https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch in c:\users\14397\appdata\roaming\python\python312\site-packages (2.2.0)
Requirement already satisfied: torchvision in c:\users\14397\appdata\roaming\python\python312\site-packages (0.17.0)
Collecting torchaudioUsing cached https://download.pytorch.org/whl/cu118/torchaudio-2.2.0%2Bcu118-cp312-cp312-win_amd64.whl (3.9 MB)
Requirement already satisfied: filelock in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.13.1)
Requirement already satisfied: typing-extensions>=4.8.0 in c:\python312\lib\site-packages (from torch) (4.9.0)
Requirement already satisfied: sympy in c:\python312\lib\site-packages (from torch) (1.12)
Requirement already satisfied: networkx in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.2.1)
Requirement already satisfied: jinja2 in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (3.1.3)
Requirement already satisfied: fsspec in c:\users\14397\appdata\roaming\python\python312\site-packages (from torch) (2024.2.0)
Requirement already satisfied: numpy in c:\python312\lib\site-packages (from torchvision) (1.26.4)
Requirement already satisfied: requests in c:\users\14397\appdata\roaming\python\python312\site-packages (from torchvision) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\python312\lib\site-packages (from torchvision) (10.2.0)
Collecting torchDownloading https://download.pytorch.org/whl/cu118/torch-2.2.0%2Bcu118-cp312-cp312-win_amd64.whl (2704.2 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 GB 1.5 MB/s eta 0:00:00
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\14397\appdata\roaming\python\python312\site-packages (from jinja2->torch) (2.1.5)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\14397\appdata\roaming\python\python312\site-packages (from requests->torchvision) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in c:\users\14397\appdata\roaming\python\python312\site-packages (from requests->torchvision) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\python312\lib\site-packages (from requests->torchvision) (2.2.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\14397\appdata\roaming\python\python312\site-packages (from requests->torchvision) (2024.2.2)
Requirement already satisfied: mpmath>=0.19 in c:\python312\lib\site-packages (from sympy->torch) (1.3.0)
Installing collected packages: torch, torchaudioAttempting uninstall: torchFound existing installation: torch 2.2.0Uninstalling torch-2.2.0:Successfully uninstalled torch-2.2.0

安装成功。

解决方案:

网络问题,继续装看运气。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/682534.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

petalinux2018.3安装步骤

1、虚拟机安装ubuntu-16.04.7-desktop-amd64.iso &#xff08;注意&#xff1a;安装ubuntu-18.04.6-desktop-amd64.iso和ubuntu-16.04.6-desktop-i386.iso会报以下错误&#xff09; environment: line 314: ((: 10 #15~1 > 10 #3: syntax error in expression (error toke…

C#中使用 => 运算符的 switch 表达式

目录 一、关于switch 语句 1.switch 语句及语法结构 2.switch 语句的一些重要注意事项 3.通常情况下的示例 1.示例1 2.示例2 二、使用 > 运算符的 switch 表达式 1.关于switch表达式 2.示例1 3.示例2 一、关于switch 语句 1.switch 语句及语法结构 C# 中的 swit…

有用的 Bash 别名和函数简介

简介 随着你在命令行上的操作越来越多&#xff0c;你会发现你使用的大部分命令只是可用命令的一个非常小的子集。大多数任务是习惯性的&#xff0c;你可能每天都以相同的方式运行这些任务。 虽然许多常见命令实用程序的制造者已经尝试通过使用缩短的名称&#xff08;想想每天…

【Springboot】参数校验 spring-boot-starter-validation

# 第一步&#xff1a;引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId><version>xxx</version> </dependency> # 第二步&#xff1a;实体类添加…

Excel

1、Excel的学习路径 2、掌握excel的基础要求 01、保证新版本 02、培养好的数据表格习惯 03、主动性探索 04、多联系 一、函数 二、文本清洗函数 三、常见文本的清洗函数 获取k的位置 FIND("k",P2,1) 从第1个位置开始在位置P2&#xff0c;查询字段k&#x…

Java+SpringBoot+Vue:高校科研管理的技术革新

✍✍计算机编程指导师 ⭐⭐个人介绍&#xff1a;自己非常喜欢研究技术问题&#xff01;专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目&#xff1a;有源码或者技术上的问题欢迎在评论区一起讨论交流&#xff01; ⚡⚡ Java实战 |…

ChatGPT高效提问—prompt实践(智能开发)

ChatGPT高效提问—prompt实践&#xff08;智能开发&#xff09; ​ 如果你是一名程序员&#xff0c;一定有过这样的经历&#xff1a;排查某个bug话费好几个小时&#xff0c;在各个搜索引擎尝试搜索&#xff0c;浏览了几十甚至上百个网站&#xff0c;结果搜到的答案千篇一律&am…

websocket简易基操

一、概述 1.1 简介 WebSocket是HTML5下一种新的协议&#xff08;websocket协议本质上是一个基于tcp的协议&#xff09;&#xff0c;它实现了浏览器与服务器全双工通信&#xff0c;能更好的节省服务器资源和带宽并达到实时通讯的目的&#xff0c;Websocket是一个持久化的协议。…

【STM32 CubeMX】GPIO的工作模式

文章目录 前言一、有哪些工作模式&#xff1f;1.1 GPIO的详细介绍1.2 GPIO的内部框图输入模式输出部分 总结 前言 在嵌入式系统开发中&#xff0c;对于STM32微控制器的GPIO&#xff08;General Purpose Input/Output&#xff09;引脚的配置和使用是至关重要的。GPIO引脚可以通…

基本算法--贪心

1.简述 贪心法的效率非常高&#xff0c;复杂度常常为O&#xff08;1&#xff09;&#xff0c;是一种局部最优的解题方法&#xff0c;而很多问题都需要求全局最优&#xff0c;&#xff0c;所以在使用贪心法之前需要评估是否能从局部最优推广到全局最优。 2.思路 作为算法的贪…

【解决】配置文件YAML: application.yml Cannot resolve configuration property ‘xxxx‘

配置文件YAML: application.yml Cannot resolve configuration property xxxx 问题排查解决 问题 在application.yml文件里面配置Bean的初始值&#xff0c;但是报错如下&#xff1a; Cannot resolve configuration property person.lastName 排查 我们先去Bean检查是否拼写…

【国产MCU】-CH32V307-通用定时器(GPTM)-输入捕获模式测量脉冲

通用定时器(GPTM)-输入捕获模式测量脉冲 文章目录 通用定时器(GPTM)-输入捕获模式测量脉冲1、通用定时器(GPTM)介绍2、输入捕获模式3、驱动API介绍4、定时器输入捕获示例CH32V307的通用定时器模块包含一个16 位可自动重装的定时器(TIM2、TIM3、TIM4和TIM5),用于测量脉…

C语言函数的实参与形参

概念&#xff1a; 函数调用中的参数&#xff0c;被称为实参&#xff0c;即 arguments函数定义中的参数&#xff0c;被称为形参&#xff0c;即 parameters 实参与形参的关系&#xff1a; 实参于形参的类型和个数必须一一对应。形参的值由实参初始化。形参与实参位于不同的内存区…

基于函数计算AIGC图片识别

目录 在 OSS 中建立图片目录 在函数计算中基于模板创建ImageAI应用 体验ImageAI图像识别效果 我们不但可以基于函数计算创建AIGC应用&#xff0c;实现以文生图&#xff0c;同时我们也可以基于函数计算创建ImageAI应用&#xff0c;通过简单几步实现对图片中对象的识别。下面我…

【运维测试】测试理论+工具总结笔记第1篇:测试理论的主要内容(已分享,附代码)

本系列文章md笔记&#xff08;已分享&#xff09;主要讨论测试理论测试工具相关知识。Python测试理论的主要内容&#xff0c;掌握软件测试的基本流程&#xff0c;知道软件测试的V和W模型的优缺点&#xff0c;掌握测试用例设计的要素&#xff0c;掌握等价类划分法、边界值法、因…

12.12 校招 实习 内推 面经

绿*泡*泡VX&#xff1a; neituijunsir 交流裙 &#xff0c;内推/实习/校招汇总表格 1、实习 | 比亚迪2024年实习生招聘&#xff01; 实习 | 比亚迪2024年实习生招聘&#xff01; 2、校招 | 上海飒智智能科技有限公司2024校园招聘 校招 | 上海飒智智能科技有限公司2024校园…

qt“五彩斑斓“ opengl

本篇文章我们来描述一下opengl相关知识 我们先看一下opengl渲染的效果 很漂亮&#xff1f; 那下面就来介绍一下这么漂亮的opengl OpenGL&#xff08;Open Graphics Library&#xff09;是一个跨平台的图形编程接口&#xff0c;用于渲染2D和3D图形。它提供了一系列函数和数据结…

Zotero插件分享(第二弹)

今天紧接上一篇文章&#xff08;Zotero常用插件分享&#xff09;&#xff0c;继续分享关于Zotero常用插件的相关内容。&#xff08;排名不分先后&#xff09; 1.Translate for Zotero 英文文献阅读辅助工具&#xff0c;可以实现将pdf中选中的文字翻译为指定语言&#xff0c;并…

Git中Idea操作git及Git Flow

目录 一、Idea中使用Git 1.idea配置Git和Gitee 2.实践操作 1.将本地项目推送到远程 2.从远程库克隆项目到本地 二、Git Flow 1.什么是Git Flow 2.工作流程 3.实践操作 一、Idea中使用Git 1.idea配置Git和Gitee 第一步&#xff1a;设置git.exe的安装路径 在设置中的…

知识碎片-mvn install时不需要mybatis-generator重新生成代码

背景 每一次项目编译的时候&#xff0c;Mybatis-Plus会重新生成代码&#xff0c;导致手动添加的Mapper和Data等注解失效 解决 在phase标签修改为deploy阶段或选择不覆盖已经存在的文件。 <plugin><groupId>org.mybatis.generator</groupId><artifactI…