安装FARM-Haystack导致PyTorch降级引发CUDA兼容性问题
GPU运行Haystack的CUDA兼容性问题
问题概述
安装farm-haystack[docstores-gpu,faiss-gpu]时,PyTorch会被强制降级到torch<1.13,>1.9版本,导致其配套的CUDA版本(10.2)无法兼容RTX 3060的sm_86算力,触发兼容性错误。
错误信息
NVIDIA GeForce RTX 3060 with CUDA capability sm_86 is not compatible with the current PyTorch installation. The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70. If you want to use the NVIDIA GeForce RTX 3060 GPU with PyTorch, please check the instructions at
复现步骤
- 用conda创建全新虚拟环境
- 安装PyTorch 1.13:
此时版本验证:pip3 install torch torchvision torchaudio>>> torch.__version__ '1.13.0' >>> torch.version.cuda '11.7' - 安装带GPU支持的Haystack:
安装过程中会自动下载pip3 install 'farm-haystack[docstores-gpu,faiss-gpu]'torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl,强制降级PyTorch - 再次验证版本:
>>> torch.__version__ '1.12.1+cu102' >>> torch.version.cuda '10.2'
解决方法
方法1:拆分安装,避免自动降级
先安装不带GPU依赖的Haystack核心包,再手动安装兼容的FAISS-GPU:
# 先安装Haystack核心 pip3 install farm-haystack # 单独安装FAISS-GPU,跳过依赖检查 pip3 install faiss-gpu --no-deps
这种方式不会触发PyTorch版本降级,同时保留GPU加速能力。
方法2:强制指定PyTorch版本安装
安装Haystack时明确指定要保留的PyTorch版本,让pip优先满足版本约束:
pip3 install 'farm-haystack[docstores-gpu,faiss-gpu]' torch==1.13.0 torchvision torchaudio
方法3:修改源码约束后本地安装
如果前两种方法无效,可克隆Haystack源码,修改版本约束后本地安装:
git clone Haystack官方源码仓库 cd haystack
编辑setup.py文件,将PyTorch的版本限制从torch<1.13,>=1.9改为torch>=1.9,然后执行:
pip3 install -e '.[docstores-gpu,faiss-gpu]'
内容的提问来源于stack exchange,提问作者eboraks
相关产品推荐
相关产品推荐

