赞
踩
在网上试了很多解决办法,终于解决。
想要运行mamba-2,需要安装causal-conv1d>=1.4.0这是官方github中说的。
关于mamba_ssm版本我安装了2.2.2。
下图是我安装的两个版本,
注意:我选择的是两个FALSE版本,我第一次安装的时候causal-conv1d选择了TRUE版本所以出现了上述问题。后面,我卸载了之后重装了FALSE版本就没有这个问题了。
还有就是,如果你是第一次安装可以参考我之前写的博客。
如果你是已经安装过1.0版本的,最好是先卸载在装1.0版本的,因为我第一次没卸载1.0,直接安装1.4还是出现了标题的问题,但是后面卸载后重装就没有这个问题了。
mamba_ssm:Releases · state-spaces/mamba · GitHub
我解决标题的问题之后,又出现了,上述问题。
按照作者的回复,Please use triton >= 2.1.0
我安装了triton = 2.2.0
就成功了。
- import torch
- from mamba_ssm import Mamba
-
- batch, length, dim = 2, 64, 16
- x = torch.randn(batch, length, dim).to("cuda")
- model = Mamba(
- # This module uses roughly 3 * expand * d_model^2 parameters
- d_model=dim, # Model dimension d_model
- d_state=16, # SSM state expansion factor
- d_conv=4, # Local convolution width
- expand=2, # Block expansion factor
- ).to("cuda")
- y = model(x)
- print("Mamba result", y.shape)
- assert y.shape == x.shape
-
- import torch
- from mamba_ssm import Mamba2
-
- batch, length, dim = 2, 64, 512
- x = torch.randn(batch, length, dim).to("cuda")
- model = Mamba2(
- # This module uses roughly 3 * expand * d_model^2 parameters
- # make sure d_model * expand / headdim = multiple of 8
- d_model=dim, # Model dimension d_model
- d_state=64, # SSM state expansion factor, typically 64 or 128
- d_conv=4, # Local convolution width
- expand=2, # Block expansion factor
- headdim=64, # default 64
- ).to("cuda")
- y = model(x)
- print("Mamba2 result", y.shape)
- assert y.shape == x.shape

以下是运行结果
Mamba result torch.Size([2, 64, 16])
Mamba2 result torch.Size([2, 64, 512])
希望可以帮助到你!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。