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

相关推荐
happylifetree15 分钟前
Python14:核心语法-数据存储与运算-字符串定义
python
液态不合群16 分钟前
AI低代码选型终局:SaaS轻量化vs私有化可控性深度博弈
人工智能·低代码·数字化·ai低代码
千里码aicood17 分钟前
基于cnn和transformer的卡通图像质量评价
人工智能·cnn·transformer
hhb_61818 分钟前
AIRAGDebug:一键定位RAG链路异常
人工智能·python·算法
无忧智库36 分钟前
AI分镜提示词怎么选
人工智能·ai
小静AI工程实验室39 分钟前
asyncio.Queue 有界队列实战:背压、task_done、join 与异常收尾
python
小凡geo43 分钟前
本地商家 GEO:用脚本一键生成 FAQPage 结构化数据,让 AI 切片更稳
开发语言·人工智能·python·microsoft·搜索引擎·ai
xiaohua100944 分钟前
AI-CLI
人工智能
Zhou1411361 小时前
SpringBoot_03_Web开发
前端·spring boot·python
u1301301 小时前
AI 日报(2026年9月30日)
人工智能