state-spaces / mamba

Mamba SSM architecture
Apache License 2.0
13.38k stars 1.14k forks source link

Unable to install `mamba-ssm` on Linux with CUDA 12.1 and PyTorch 2.5.1 #634

Open Eom-taeseon opened 2 days ago

Eom-taeseon commented 2 days ago

I'm trying to install mamba-ssm with pip install mamba-ssm but it doesn't work. I need help These are my systems

CUDA : 12.1
PyTorch : 2.5.1
Python : 3.11.10
os : Linux 5.15.0-10-generic
Architecture : x86-64

I checked all the mamba-ssm released version(https://github.com/state-spaces/mamba/releases) and there was nothing for mine. Is this the reason why I can't install it?

Below is my errored bash code

(eom_hymba) pcn_u8@localhost:~$ pip install mamba-ssm
Collecting mamba-ssm
  Using cached mamba_ssm-2.2.2.tar.gz (85 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: torch in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from mamba-ssm) (2.5.1+cu121)
Requirement already satisfied: packaging in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from mamba-ssm) (24.2)
Requirement already satisfied: ninja in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from mamba-ssm) (1.11.1.2)
Collecting einops (from mamba-ssm)
  Using cached einops-0.8.0-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: triton in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from mamba-ssm) (3.1.0)
Requirement already satisfied: transformers in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from mamba-ssm) (4.46.3)
Requirement already satisfied: filelock in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (3.13.1)
Requirement already satisfied: typing-extensions>=4.8.0 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (4.12.2)
Requirement already satisfied: networkx in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (3.2.1)
Requirement already satisfied: jinja2 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (3.1.3)
Requirement already satisfied: fsspec in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (2024.2.0)
Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.105)
Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.105)
Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.105)
Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (9.1.0.70)
Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.3.1)
Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (11.0.2.54)
Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (10.3.2.106)
Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (11.4.5.107)
Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.0.106)
Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (2.21.5)
Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (12.1.105)
Requirement already satisfied: sympy==1.13.1 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from torch->mamba-ssm) (1.13.1)
Requirement already satisfied: nvidia-nvjitlink-cu12 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch->mamba-ssm) (12.1.105)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from sympy==1.13.1->torch->mamba-ssm) (1.3.0)
Requirement already satisfied: huggingface-hub<1.0,>=0.23.2 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (0.26.3)
Requirement already satisfied: numpy>=1.17 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (1.26.3)
Requirement already satisfied: pyyaml>=5.1 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (6.0.2)
Requirement already satisfied: regex!=2019.12.17 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (2024.11.6)
Requirement already satisfied: requests in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (2.32.3)
Requirement already satisfied: tokenizers<0.21,>=0.20 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (0.20.3)
Requirement already satisfied: safetensors>=0.4.1 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (0.4.5)
Requirement already satisfied: tqdm>=4.27 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from transformers->mamba-ssm) (4.67.1)
Requirement already satisfied: MarkupSafe>=2.0 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from jinja2->torch->mamba-ssm) (2.1.5)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from requests->transformers->mamba-ssm) (3.4.0)
Requirement already satisfied: idna<4,>=2.5 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from requests->transformers->mamba-ssm) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from requests->transformers->mamba-ssm) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages (from requests->transformers->mamba-ssm) (2024.8.30)
Using cached einops-0.8.0-py3-none-any.whl (43 kB)
Building wheels for collected packages: mamba-ssm
  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
  ╰─> [152 lines of output]

      torch.__version__  = 2.5.1+cu121

      running bdist_wheel
      Guessing wheel URL:  https://github.com/state-spaces/mamba/releases/download/v2.2.2/mamba_ssm-2.2.2+cu122torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
      Precompiled wheel not found. Building from source...
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm
      copying mamba_ssm/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/mlp.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/mamba2.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/mamba2_simple.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/ssd_minimal.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/mamba_simple.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/mha.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      copying mamba_ssm/modules/block.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/modules
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/models
      copying mamba_ssm/models/config_mamba.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/models
      copying mamba_ssm/models/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/models
      copying mamba_ssm/models/mixer_seq_simple.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/models
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/utils
      copying mamba_ssm/utils/generation.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/utils
      copying mamba_ssm/utils/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/utils
      copying mamba_ssm/utils/hf.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/utils
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/distributed
      copying mamba_ssm/distributed/tensor_parallel.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/distributed
      copying mamba_ssm/distributed/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/distributed
      copying mamba_ssm/distributed/distributed_utils.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/distributed
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/ops
      copying mamba_ssm/ops/selective_scan_interface.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops
      copying mamba_ssm/ops/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops
      creating build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/layer_norm.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/ssd_chunk_state.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/layernorm_gated.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/selective_state_update.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/k_activations.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/ssd_bmm.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/ssd_combined.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/ssd_chunk_scan.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/__init__.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/ssd_state_passing.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      copying mamba_ssm/ops/triton/softplus.py -> build/lib.linux-x86_64-cpython-311/mamba_ssm/ops/triton
      running build_ext
      /home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py:426: UserWarning: There are no g++ version bounds defined for CUDA version 12.1
        warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
      building 'selective_scan_cuda' extension
      creating /tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/build/temp.linux-x86_64-cpython-311/csrc/selective_scan
      Emitting ninja build file /tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/build/temp.linux-x86_64-cpython-311/build.ninja...
      Compiling objects...
      Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
      ninja: error: '/tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/csrc/selective_scan/selective_scan.cpp', needed by '/tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/build/temp.linux-x86_64-cpython-311/csrc/selective_scan/selective_scan.o', missing and no known rule to make it
      Traceback (most recent call last):
        File "/tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/setup.py", line 318, in run
          urllib.request.urlretrieve(wheel_url, wheel_filename)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 241, in urlretrieve
          with contextlib.closing(urlopen(url, data)) as fp:
                                  ^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 216, in urlopen
          return opener.open(url, data, timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 525, in open
          response = meth(req, response)
                     ^^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 634, in http_response
          response = self.parent.error(
                     ^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 563, in error
          return self._call_chain(*args)
                 ^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 496, in _call_chain
          result = func(*args)
                   ^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/urllib/request.py", line 643, in http_error_default
          raise HTTPError(req.full_url, code, msg, hdrs, fp)
      urllib.error.HTTPError: HTTP Error 404: Not Found

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2104, in _run_ninja_build
          subprocess.run(
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/setup.py", line 337, in <module>
          setup(
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 183, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
          dist.run_commands()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
          self.run_command(cmd)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-9abbcbav/mamba-ssm_a2ee6f3b2a12458fa60d9ef8c70cd385/setup.py", line 335, in run
          super().run()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/wheel/_bdist_wheel.py", line 378, in run
          self.run_command("build")
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 98, in run
          _build_ext.run(self)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 359, in run
          self.build_extensions()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 868, in build_extensions
          build_ext.build_extensions(self)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 476, in build_extensions
          self._build_extensions_serial()
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 502, in _build_extensions_serial
          self.build_extension(ext)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 263, in build_extension
          _build_ext.build_extension(self, ext)
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 557, in build_extension
          objects = self.compiler.compile(
                    ^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 681, in unix_wrap_ninja_compile
          _write_ninja_file_and_compile_objects(
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1784, in _write_ninja_file_and_compile_objects
          _run_ninja_build(
        File "/home/pcn_rns/anaconda3/envs/eom_hymba/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2120, in _run_ninja_build
          raise RuntimeError(message) from e
      RuntimeError: Error compiling objects for extension
      [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: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mamba-ssm)

Would you be able to provide guidance on how to resolve this issue? Thank you in advance!

pjvalla commented 1 day ago

I have the same exact error: CUDA : 12.4 PyTorch : 2.5.1 Python : 3.12.3 os : Linux 5.4.0-198-generic Architecture : x86-64

Eom-taeseon commented 20 hours ago

I solve this problem!! I tried 3 ways.

  1. Update CUDA Version Actually, I'm using an external server with my colleagues, so I haven't tried this method. But if it's a server using alone, I think it's well worth trying.

  2. Install Wheel file in local https://github.com/state-spaces/mamba/releases Go into the url, and find approriate version which fit with your system. Below is what you have to check,

    • CUDA Version(cu)
    • PyTorch Version(torch)
    • Python Version(cp)
    • os(x86-64)

Unfortunately, my system doesn't fit with them. So I have to find another method.

  1. Clone the git and install This works for me.
    git clone https://github.com/state-spaces/mamba.git
    cd mamba
    pip install -e .

    If you got same error, try another one.

git clone https://github.com/state-spaces/mamba.git
cd mamba
python setup.py install

I hope this method helps you resolve your errors as well. Good Luck!! :D