NX-AI / xlstm

Official repository of the xLSTM.
GNU Affero General Public License v3.0
918 stars 66 forks source link

RuntimeError: Ninja is required to load C++ extensions #12

Open jabowery opened 3 weeks ago

jabowery commented 3 weeks ago

After: (xlstm) jabowery@jaboweryML:~/devel/xlstm$ python experiments/main.py --config experiment/parity_xlstm01.yaml to fix this issue:

{'verbose': True, 'with_cuda': True, 'extra_ldflags': ['-L/home/jabowery/mambaforge/envs/xlstm/lib', '-lcublas'], 'extra_cflags': ['-DSLSTM_HIDDEN_SIZE=64', '-DSLSTM_BATCH_SIZE=8', '-DSLSTM_NUM_HEADS=1', '-DSLSTM_NUM_STATES=4', '-DSLSTM_DTYPE_B=float', '-DSLSTM_DTYPE_R=__nv_bfloat16', '-DSLSTM_DTYPE_W=__nv_bfloat16', '-DSLSTM_DTYPE_G=__nv_bfloat16', '-DSLSTM_DTYPE_S=__nv_bfloat16', '-DSLSTM_DTYPE_A=float', '-DSLSTM_NUM_GATES=4', '-DSLSTM_SIMPLE_AGG=true', '-DSLSTM_GRADIENT_RECURRENT_CLIPVAL_VALID=false', '-DSLSTM_GRADIENT_RECURRENT_CLIPVAL=0.0', '-DSLSTM_FORWARD_CLIPVAL_VALID=false', '-DSLSTM_FORWARD_CLIPVAL=0.0', '-U__CUDA_NO_HALF_OPERATORS__', '-U__CUDA_NO_HALF_CONVERSIONS__', '-U__CUDA_NO_BFLOAT16_OPERATORS__', '-U__CUDA_NO_BFLOAT16_CONVERSIONS__', '-U__CUDA_NO_BFLOAT162_OPERATORS__', '-U__CUDA_NO_BFLOAT162_CONVERSIONS__'], 'extra_cuda_cflags': ['-Xptxas="-v"', '-gencode', 'arch=compute_80,code=compute_80', '-res-usage', '--use_fast_math', '-O3', '-Xptxas -O3', '--extra-device-vectorization', '-DSLSTM_HIDDEN_SIZE=64', '-DSLSTM_BATCH_SIZE=8', '-DSLSTM_NUM_HEADS=1', '-DSLSTM_NUM_STATES=4', '-DSLSTM_DTYPE_B=float', '-DSLSTM_DTYPE_R=__nv_bfloat16', '-DSLSTM_DTYPE_W=__nv_bfloat16', '-DSLSTM_DTYPE_G=__nv_bfloat16', '-DSLSTM_DTYPE_S=__nv_bfloat16', '-DSLSTM_DTYPE_A=float', '-DSLSTM_NUM_GATES=4', '-DSLSTM_SIMPLE_AGG=true', '-DSLSTM_GRADIENT_RECURRENT_CLIPVAL_VALID=false', '-DSLSTM_GRADIENT_RECURRENT_CLIPVAL=0.0', '-DSLSTM_FORWARD_CLIPVAL_VALID=false', '-DSLSTM_FORWARD_CLIPVAL=0.0', '-U__CUDA_NO_HALF_OPERATORS__', '-U__CUDA_NO_HALF_CONVERSIONS__', '-U__CUDA_NO_BFLOAT16_OPERATORS__', '-U__CUDA_NO_BFLOAT16_CONVERSIONS__', '-U__CUDA_NO_BFLOAT162_OPERATORS__', '-U__CUDA_NO_BFLOAT162_CONVERSIONS__']}
Using /home/jabowery/.cache/torch_extensions/py311_cu121 as PyTorch extensions root...
Creating extension directory /home/jabowery/.cache/torch_extensions/py311_cu121/slstm_HS64BS8NH1NS4DBfDRbDWbDGbDSbDAfNG4SA1GRCV0GRC0d0FCV0FC0d0...
Traceback (most recent call last):
  File "/home/jabowery/devel/xlstm/experiments/main.py", line 155, in <module>
    main(cfg)
  File "/home/jabowery/devel/xlstm/experiments/main.py", line 51, in main
    model = xLSTMLMModel(from_dict(xLSTMLMModelConfig, OmegaConf.to_container(cfg.model))).to(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/xlstm_lm_model.py", line 29, in __init__
    self.xlstm_block_stack = xLSTMBlockStack(config=config)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/xlstm_block_stack.py", line 83, in __init__
    self.blocks = self._create_blocks(config=config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/xlstm_block_stack.py", line 104, in _create_blocks
    blocks.append(sLSTMBlock(config=config))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/block.py", line 32, in __init__
    super().__init__(
  File "/home/jabowery/devel/xlstm/xlstm/blocks/xlstm_block.py", line 62, in __init__
    self.xlstm = sLSTMLayer(config=self.config.slstm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/layer.py", line 78, in __init__
    self.slstm_cell = sLSTMCell(self.config)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/cell.py", line 780, in __new__
    return sLSTMCell_cuda(config, skip_backend_init=skip_backend_init)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/cell.py", line 690, in __init__
    self.func = sLSTMCellFuncGenerator(self.training, config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/cell.py", line 536, in sLSTMCellFuncGenerator
    slstm_cuda = sLSTMCellCUDA.instance(config=config)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/cell.py", line 515, in instance
    cls.mod[repr(config)] = load(
                            ^^^^^
  File "/home/jabowery/devel/xlstm/xlstm/blocks/slstm/src/cuda_init.py", line 84, in load
    mod = _load(name + suffix, sources, **myargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabowery/mambaforge/envs/xlstm/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1306, in load
    return _jit_compile(
           ^^^^^^^^^^^^^
  File "/home/jabowery/mambaforge/envs/xlstm/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/jabowery/mambaforge/envs/xlstm/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1793, in _write_ninja_file_and_build_library
    verify_ninja_availability()
  File "/home/jabowery/mambaforge/envs/xlstm/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1842, in verify_ninja_availability
    raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extensions
liujike commented 3 weeks ago

I also have this problem,uh...

stefan-it commented 3 weeks ago

Hi,

I could fix that by installing pip3 install Ninja :)

salah55s commented 3 weeks ago

Hello, @stefan-it could you please share your setup, what is your GPU ,the version of Cuda... having a GCC?

I also have the same problem, and installing Ninja does not make it work, I think I have an error with the installed c++ libraries in my PC, and I do not know how to investigate it

thanks.

UlanqabBadGuy commented 2 weeks ago

@salah55s Hi, I also have the problem which is same as yours. Have you solved it?

salah55s commented 2 weeks ago

@UlanqabBadGuy it will work fine for a Linux-based dev.. for windows, lots of bugs will show up

make sure you can run a c/c++ code in your env. It should solve the problem I think

see the requ , and do it, it's the better way to set it up , and also make sure u have a capable GPU