[快修] mamba 2模块安装时出现Failed building wheel for mamba-ssm和urlopen error的修复方法

问题

本文介绍一种mamba 2模块安装时出现Failed building wheel for mamba-ssm和urlopen error的修复方法。完整的错误信息应当是这样的

  Building wheel for mamba-ssm (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      
      
      torch.__version__  = 2.4.0
      
      
      running bdist_wheel
      Guessing wheel URL:  https://github.com/state-spaces/mamba/releases/download/v2.2.2/mamba_ssm-2.2.2+cu122torch2.4cxx11abiFALSE-cp312-cp312-linux_x86_64.whl
      error: <urlopen error [Errno 110] Connection timed out>
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mamba-ssm
  Running setup.py clean for mamba-ssm
Failed to build mamba-ssm
ERROR: Could not build wheels for mamba-ssm, which is required to install pyproject.toml-based projects

原因

推测为mamba-ssm模块官方在编写Python模块时,在setup.py中根据用户已安装的torch版本自动下载wheel文件安装。这样导致用户设置的pypi镜像源无法替换setup.py中的wheel地址,在网络环境不同时,会出现无法访问wheel地址的情况,导致出现urlopen错误。
综上这其实是一个简单的网络错误,而非编译wheel的错误。

在Python的软件包中,setup.py大多数用来构建wheel。但mamba-ssm没有使用标准的wheel模块, 也没有使用setup.py模块进行标准的wheel构建任务,而是用setup.py来下载wheel, 这样做虽然提高了用户安装时无需自行选择包的cuda版本的开发体验,但也导致了出现网络错误时出现的build wheels错误会很有迷惑性。

修复

最正确的修复方式是找到setup.py,将其中的wheel地址换位能够正常访问的地址。但奈何没有时间查找pip下载的setup.py的位置,于是就直接用pip安装匹配到的wheel。

比如错误信息中出现

Guessing wheel URL:  https://github.com/state-spaces/mamba/releases/download/v2.2.2/mamba_ssm-2.2.2+cu122torch2.4cxx11abiFALSE-cp312-cp312-linux_x86_64.whl

我们就直接通过镜像安装wheel

pip install https://mirror.ghproxy.net/https://github.com/state-spaces/mamba/releases/download/v2.2.2/mamba_ssm-2.2.2+cu122torch2.4cxx11abiFALSE-cp312-cp312-linux_x86_64.whl

即可正常安装。

环境:

  • Ubuntu 24.04 x86_64
  • CUDA 12.4
  • Anaconda 24.1.2
  • Python 3.12
  • PyTorch 2.4
  • mamba-ssm 2.2.2

本文只涵盖了对于此种错误信息的一种常见原因和解决方法,同样错误的成因可能是复杂多样的,请结合具体情况具体分析。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值