【已解决】在已有的pytorch环境下装mamba-ssm和causal-conv1d
问题描述Ubuntu操作系统已有Pytorch的情况下装mamba-ssm和causal-conv1d以下尝试pip install --no-cache-dir --no-build-isolation causal_conv1d1.5.0.post8 -vgit clone https://github.com/lmnt-com/causal-conv1d.git cd causal-conv1d都没有成功装上考虑到版本兼容的问题不想通过创建新的虚拟环境和安装不确定是否兼容版本Pytorch反复尝试。解决办法切换到已经装好 torch 和 torchvision 的虚拟环境下1. 检查版本查看Python版本Python 3.8.20python--version查看torch和cuda版本确认可用2.1.0cu118 Truepython-cimport torch; print(torch.__version__, torch.cuda.is_available())2. 下载 mamba_ssm 和 causal-conv 的 .whl 文件mamba_ssmcausal-conv1d慎选最新版以v1.2.1为例mamba-ssm和causal-conv的版本应该保持一致。这里我选FALSE的装成了TRUE则不兼容。原因可能是两者区别在于编译时是否启用 C11 ABI。cxx11abiFALSE → 旧 ABI和当前 PyTorch 2.1 编译的符号一致所以导入成功。mamba-ssm同理。3. 本地安装pipinstallmamba_ssm-1.2.1cu118torch2.1cxx11abiFALSE-cp38-cp38-linux_x86_64.whlpipinstallcausal_conv1d-1.2.1cu118torch2.1cxx11abiFALSE-cp38-cp38-linux_x86_64.whl4. 验证python-cimport torch, mamba_ssm, causal_conv1d; print(torch.__version__, torch.cuda.is_available())输出 2.1.0cu118 True说明成了。补充说明参考 mamba_ssm和causal-conv1d详细安装教程感谢大佬分享由于之前不兼容安装TRUE的版本再去装FALSE的就会提示此前已经装了相同的版本但是报 ImportError。为此应先卸载旧的并且清理缓存然后再重新安装# 卸载旧版本pip uninstall mamba_ssm causal_conv1d-y# 清除 pip 缓存pip cache purge# 安装 mamba-ssmpipinstall--no-cache-dir mamba_ssm-1.2.1cu118torch2.1cxx11abiFALSE-cp38-cp38-linux_x86_64.whl# 安装 causal-conv1dpipinstall--no-cache-dir causal_conv1d-1.2.1cu118torch2.1cxx11abiFALSE-cp38-cp38-linux_x86_64.whl