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

相关推荐
Albert Edison3 小时前
【Python】学生管理系统
开发语言·数据库·python
love530love5 小时前
【ComfyUI】解决 ModuleNotFoundError: No module named ‘inference_core_nodes‘ 问题
人工智能·windows·python·comfyui·inference-core
大模型任我行5 小时前
华为:构建特征级LLM编码评测基准
人工智能·语言模型·自然语言处理·论文笔记
Jason_Honey25 小时前
【平安Agent算法岗面试-二面】
人工智能·算法·面试
Godspeed Zhao6 小时前
现代智能汽车中的无线技术106——ETC(0)
网络·人工智能·汽车
恋猫de小郭6 小时前
AGENTS.md 真的对 AI Coding 有用吗?或许在此之前你没用对?
前端·人工智能·ai编程
久邦科技6 小时前
OpenCode 完整入门(安装 + 配置 + 使用 + 模板)
人工智能
zhangshuang-peta6 小时前
模型上下文协议(MCP):演进历程、功能特性与Peta的崛起
人工智能·ai agent·mcp·peta
heimeiyingwang6 小时前
企业供应链 AI 优化:需求预测与智能调度
大数据·数据库·人工智能·机器学习