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

相关推荐
深蓝AI18 小时前
不调模型不改壳:CMU 开源 Hermit,给 Agent 外挂一个能训练的适配器
人工智能·agent
汤姆宝库20 小时前
世界模型深拆:视频生成、潜在模拟与物理直觉
人工智能
weixin_468466851 天前
从“看懂”到“做到”:视觉-语言-动作模型如何让机器人真正执行指令
人工智能·ai·机器人·大语言模型·前沿科技
朋友圈自动点赞工具1 天前
科学AI插件化:从蛋白质结构到古籍修复
人工智能
龙粤GEO1 天前
实体Entity在GEO中代表什么含义
人工智能
前端精髓1 天前
结构化输出with_structured_output(抽卡)
python·langchain
听风吹等浪起1 天前
第26章:ViT+InceptionDW+FocalLoss改进|CT骨折影像二分类完整Pytorch实现(含PyQt5推理GUI)
pytorch·qt·分类
尹人入圣1 天前
目前热门的IP驱动产业新场景新工具
网络·python·网络协议·tcp/ip
剑雨巍巍1 天前
AI Agent面试之基础概念
人工智能
微帧Visionular1 天前
AI视频单帧清晰,播放时却闪烁,原因是什么?
人工智能·深度学习·音视频