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

相关推荐
花酒锄作田25 分钟前
[python]argparse 包在聊天机器人中的应用
python
久违 °3 小时前
【AI-Agent】TagMatrix 数据标注工具开发
人工智能·数据分析·go·agent·数据隐私
NiceCloud喜云3 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
AI360labs_atyun3 小时前
腾讯推出电子牛马Marvis,好用吗?
人工智能·科技·ai
Dfreedom.3 小时前
Windows、虚拟机、开发板组网通信原理及调试通联步骤
人工智能·windows·部署·边缘计算·开发板·模型加速
3DVisionary3 小时前
蓝光三维扫描:医疗制造的精度焦虑怎么解
人工智能·算法·制造·蓝光三维扫描·医疗制造·三维检测·义齿检测
Are_You_Okkk_3 小时前
基于MonkeyCode解析AI研发新模式,根治开发低效痛点
大数据·人工智能·开源·ai编程
AI玫瑰助手3 小时前
Python函数:默认参数的定义与注意事项
开发语言·python·信息可视化
好评笔记3 小时前
机器学习面试八股——常用损失函数
人工智能·深度学习·算法·机器学习·校招
weixin_468466853 小时前
全局与局部注意力机制新手实战指南
人工智能·python·深度学习·算法·自然语言处理·transformer·注意力机制