CuPy调用cdist遇pylibraft未安装错误,安装pylibraft失败求助
解决CuPy中cdist函数依赖pylibraft安装失败的问题
问题背景
尝试将scipy的cdist函数迁移到GPU运行,使用CuPy对应接口时触发依赖错误,安装指定版本的pylibraft过程中再次失败。
原测试代码
from cupyx.scipy.spatial import distance as cudist import cupy as cu a = cu.array([1,2]) b = cu.array([3,4]) c = cudist.cdist(a, b, metric="euclidean")
首次运行报错
RuntimeError: pylibraft is not installed
安装pylibraft时的错误
执行官方指定命令:
pip install pylibraft-cu11 --extra-index-url=https://pypi.nvidia.com
构建wheel阶段出现错误:
RuntimeError: Bad params
环境信息
- Python 3.11
- nvcc版本:cuda_12.1.r12.1
- GPU:NVIDIA GeForce RTX 3060
- CUDA版本:12.1
解决方案
错误核心是pylibraft版本与本地CUDA版本不匹配:你安装的pylibraft-cu11适配CUDA 11.x系列,但本地CUDA版本为12.1,需安装对应CUDA 12的版本。
执行以下命令替换安装:
pip install pylibraft-cu12 --extra-index-url=https://pypi.nvidia.com
安装完成后重新运行原代码即可正常执行。
内容的提问来源于stack exchange,提问作者raceee
相关产品推荐
相关产品推荐

