使用requirements.txt文件安装cuda(GPU)版本的pytorch

使用requirements.txt文件安装cuda(GPU)版本的pytorch

问题描述

使用requirements.txt可以轻松地帮助我们配置新环境,然而,当使用requirements.txt安装pytorch时有时会出现仅能安装cpu版本pytorch的情况。

举例说明:

requirements.txt文件内容如下:

复制代码
torch==2.0.1
torchaudio==2.0.2
torchvision==0.15.2

此时在anaconda promot中输入

复制代码
pip install -r requirements.txt

然后会发现,安装的是cpu版本的pytorch

这里输出的也是False

解决方法

应该将requirements.txt文件改为如下形式

复制代码
torch==2.0.1+cu117
torchaudio==2.0.2+cu117
torchvision==0.15.2+cu117
-f https://download.pytorch.org/whl/torch_stable.html

然后再在anaconda promot中输入

复制代码
pip install -r requirements.txt

此时安装的就是cuda版本的pytorch

这里输出是True

相关推荐
庄小焱2 小时前
【AI模型】——RAG索引构建与优化
人工智能·ai·向量数据库·ai大模型·rag·rag索引·索引构建与优化
STLearner2 小时前
WSDM 2026 | 时间序列(Time Series)论文总结【预测,表示学习,因果】
大数据·论文阅读·人工智能·深度学习·学习·机器学习·数据挖掘
NotFound4862 小时前
实战分享Python爬虫,如何实现高效解析 Web of Science 文献数据并导出 CSV
前端·爬虫·python
玩转单片机与嵌入式2 小时前
不会 Python、不会深度学习,也能在STM32上跑AI模型吗?
人工智能·单片机·嵌入式硬件·嵌入式ai
CareyWYR2 小时前
我暂停了vibecoding一个月
人工智能
竹之却2 小时前
【Agent-阿程】一文搞懂大模型Token核心原理与实战避坑指南
人工智能·token
呆呆敲代码的小Y2 小时前
从LLM到Agent Skill:AI核心技术全拆解与系统化学习路线
人工智能·ai·llm·agent·优化·skill·mcp
昵称小白2 小时前
从 ( y = wx + b ) 到神经网络:参数、loss、梯度到底怎么连起来(一)
人工智能·神经网络
SmartBrain2 小时前
基于 Spring AI + Skill 工程 + MCP 技术方案研究
人工智能·spring·架构·aigc
23471021272 小时前
4.14 学习笔记
笔记·python·学习