2024.5.4 mamba环境搭建TypeError: causal_conv1d_fwd
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,直接安装
测试
(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)
)