使用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

相关推荐
Mr Robot4 分钟前
AI 赋能光伏发电量预测:从特征工程到 LSTM/XGboost 双基线实战
人工智能·能源
迪飞特科技8 分钟前
大模型接入业务系统:API、本地部署、RAG、智能体四种路线怎么选
java·数据库·人工智能·知识图谱·deepseek·本地化大模型
狂奔solar9 分钟前
Harness²:Google 如何让 AI 自己“调教“AI——递归代理优化框架深度拆解
人工智能
viperrrrrrrrrr711 分钟前
SFT 微调指南
人工智能
海姐软件测试14 分钟前
Python 自动化与 AI 结合:基于 Jenkins 的回归验证实践
人工智能·python·自动化
回眸&啤酒鸭15 分钟前
【回眸】纳米 AI 搜索效果实测与能力展示
人工智能
Haoyunyi21 分钟前
2026年做期货量化,和三年前已经不是一回事了
大数据·人工智能·python·金融·区块链
通信瓦工25 分钟前
Meta ORv3 HPR Next 机架与供电方案map
人工智能
shaibdoio30 分钟前
两项计算机软件著作权背后:AI获客系统的技术自研路径
人工智能·长沙瞬维ai
紧跟先前的步伐33 分钟前
Go AI Agent 实战 04|Prompt 与消息角色:System、User、Assistant
人工智能·golang·prompt