2024.5.4 mamba环境搭建TypeError: causal_conv1d_fwd

文章讲述了在使用Mamba环境时遇到的causal_conv1d错误,原因是版本不匹配。解决方法是找到并安装适合当前torch版本(2.1.1+cu118)的causal_conv1dwhl包,如v1.2.0.post2。
摘要由CSDN通过智能技术生成

2024.5.4 mamba环境搭建TypeError: causal_conv1d_fwd

报错:https://github.com/state-spaces/mamba

Traceback (most recent call last):
  File "/home/zzy/code/mamba/test.py", line 13, in <module>
    y = model(x)
  File "/home/zzy/local/anaconda3/envs/mambagraph/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/zzy/local/anaconda3/envs/mambagraph/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/zzy/code/mamba/mamba_ssm/modules/mamba_simple.py", line 146, in forward
    out = mamba_inner_fn(
  File "/home/zzy/code/mamba/mamba_ssm/ops/selective_scan_interface.py", line 323, in mamba_inner_fn
    return MambaInnerFn.apply(xz, conv1d_weight, conv1d_bias, x_proj_weight, delta_proj_weight,
  File "/home/zzy/local/anaconda3/envs/mambagraph/lib/python3.10/site-packages/torch/autograd/function.py", line 539, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "/home/zzy/local/anaconda3/envs/mambagraph/lib/python3.10/site-packages/torch/cuda/amp/autocast_mode.py", line 113, in decorate_fwd
    return fwd(*args, **kwargs)
  File "/home/zzy/code/mamba/mamba_ssm/ops/selective_scan_interface.py", line 190, in forward
    conv1d_out = causal_conv1d_cuda.causal_conv1d_fwd(
TypeError: causal_conv1d_fwd(): incompatible function arguments. The following argument types are supported:
    1. (arg0: torch.Tensor, arg1: torch.Tensor, arg2: Optional[torch.Tensor], arg3: Optional[torch.Tensor], arg4: bool) -> torch.Tensor

其实原因就是版本不对,不用去查其他博客了
作者的 https://github.com/state-spaces/mamba 更新了适应新版本的causal_conv1d
在这里插入图片描述
安装:

pip install causal_conv1d-1.2.0.post2.tar.gz

失败:

Building wheels for collected packages: causal_conv1d
  Building wheel for causal_conv1d (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.1.1+cu118


      running bdist_wheel
      Guessing wheel URL:  https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.2.0.post2/causal_conv1d-1.2.0.post2+cu118torch2.1cxx11abiFALSE-cp310-cp310-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 causal_conv1d
  Running setup.py clean for causal_conv1d
Failed to build causal_conv1d
ERROR: Could not build wheels for causal_conv1d, which is required to install pyproject.toml-based projects

通过提示直接下载whl文件
https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.2.0.post2/causal_conv1d-1.2.0.post2+cu118torch2.1cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

可以去找对应自己版本的whl,直接安装
测试

(mamba) zzy@ustc-gpu:~/code/mamba/tests$ python ../test.py
Mamba(
  (in_proj): Linear(in_features=16, out_features=64, bias=False)
  (conv1d): Conv1d(32, 32, kernel_size=(4,), stride=(1,), padding=(3,), groups=32)
  (act): SiLU()
  (x_proj): Linear(in_features=32, out_features=33, bias=False)
  (dt_proj): Linear(in_features=1, out_features=32, bias=True)
  (out_proj): Linear(in_features=32, out_features=16, bias=False)
)
  • 12
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值