You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Poetry安装kornia时无法找到nvidia-cudnn-cu11安装候选包

解决Poetry 1.1.13安装kornia时找不到nvidia-cudnn-cu11的问题

环境信息

  • Python 3.8.5(固定版本)
  • Poetry 1.1.13(无法升级至v1.2)

问题概述

执行poetry add kornia时出现以下错误:

RuntimeError
Unable to find installation candidates for nvidia-cudnn-cu11 (8.5.0.96)

报错位置在~.poetry\lib\poetry\installation\chooser.py第72行。已通过poetry run pip install nvidia-pyindex && poetry run pip install kornia成功用pip安装,但Poetry执行相同流程仍报错;尝试清理缓存、重建虚拟环境、添加源等操作均无效,且因Poetry版本限制无法使用poetry source add命令。

解决方案

方案1:手动配置Poetry全局源(适配1.1.x版本)

Poetry 1.1.x不支持poetry source add命令,但可通过修改全局配置文件添加NVIDIA PyPI源:

  1. 找到Poetry配置文件路径:
    • Windows:%APPDATA%\pypoetry\config.toml
    • macOS/Linux:~/.config/pypoetry/config.toml
  2. 打开配置文件,添加以下内容:
    [[repositories]]
    name = "nvidia"
    url = "https://pypi.nvidia.com"
    
  3. 保存后执行:
    poetry cache clear pypi --all
    poetry env remove python3.8
    poetry install
    poetry add kornia
    

方案2:手动指定依赖包URL绕过源限制

若方案1仍报错,可直接在pyproject.toml中指定nvidia-cudnn-cu11的下载地址:

  1. 编辑pyproject.toml,在[tool.poetry.dependencies]区块添加:
    nvidia-cudnn-cu11 = { url = "https://pypi.nvidia.com/nvidia-cudnn-cu11/nvidia_cudnn_cu11-8.5.0.96-py3-none-any.whl" }
    kornia = "*"
    
  2. 执行以下命令完成安装:
    poetry cache clear --all
    poetry env remove python3.8
    poetry install
    

方案3:基于已安装的pip依赖生成Poetry配置

若已通过poetry run pip install kornia成功安装,可将现有依赖导入Poetry:

  1. 激活虚拟环境:
    poetry shell
    
  2. 导出当前pip依赖:
    pip freeze > requirements.txt
    
  3. 将依赖批量添加到Poetry:
    poetry add $(cat requirements.txt)
    
  4. 生成新的lock文件:
    poetry lock --no-update
    

说明

  • nvidia-cudnn-cu11等NVIDIA专属包不在PyPI默认源,Poetry 1.1.x无法自动识别第三方源,需手动配置或指定URL。
  • 操作前务必清理Poetry缓存并重建虚拟环境,避免旧缓存干扰。

内容的提问来源于stack exchange,提问作者critor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 11:50:24