当使用GPU运行Haystack时,我得到以下错误。在深入研究之后,我意识到Haystack正在将Pytorch降级到与我的CUDA不兼容的版本。
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
重现Haystack降级Pytorch的步骤
用conda创建一个新的环境安装Pytorch 1.13 (pip3 Install torch torchvision torchaudio)检查Torch和Cuda版本
>>> torch.__version__
'1.13.0'
>>> torch.version.cuda
'11.7'
安装Haystack (pip3 Install 'farm-haystack[docstores-gpu,faiss-gpu]')安装程序使用旧版本的Torch收集火炬<1.13,>1.9使用缓存火炬-1.12.1-cp38-cp38-manylinux1_x86_64。whl (776.3 MB)检查Torch和Cuda版本
>>> torch.__version__
'1.12.1+cu102'
>>> torch.version.cuda
'10.2'
有两种解决方案
- 使用light-the-torch安装Pytorch 1.12与CUDA 11.6
- 从源代码安装并通过修改版本强制Pytorch版本。
1。使用light-the-torch
。创造一个环境b.安装点燃火炬(ltt) https://pypi.org/project/light-the-torch/c.使用ltt安装带有Haystack版本支持的Pytorch。我们将安装正确的CUDA版本。
ltt install torch==1.12.1
d。检查Pytorch和CUDA的版本
torch.__version__
'1.12.1+cu116'
torch.version.cuda
'11.6'
2。从源代码安装
这是我提出的解决方案,从源代码安装并配置Pytorch版本。
安装FARM并指定Pytorch版本
git clone https://github.com/deepset-ai/FARM.git
cd FARM
Edit requirement.txt to point to the right PyTorch torch>1.12.2,<1.14
pip install -r requirements.txt
pip install --editable .
cd ...
安装Haystack强制它使用特定的Pytorch版本
git clone https://github.com/deepset-ai/haystack.git
cd haystack
Edit pyproject.toml to point to the right PyTorch torch>1.12.2,<1.14
pip install --upgrade pip
pip install -e '.[docstores, docstores-gpu, faiss, faiss-gpu]'
检查火炬版本
>>> import torch
>>> torch.__version__
'1.13.0+cu117'
>>> torch.version.cuda
'11.7'