Dao-AILab / causal-conv1d

Causal depthwise conv1d in CUDA, with a PyTorch interface
BSD 3-Clause "New" or "Revised" License
332 stars 61 forks source link

causal_conv1d_cuda #9

Closed FlyPiggg121 closed 9 months ago

FlyPiggg121 commented 11 months ago

You have imported a repository named "causal_conv1d_cuda" in the code(import causal_conv1d_cuda). How can I find and download this repository?

tridao commented 11 months ago

pip install causal-conv1d will compile the CUDA part.

takeraparterer commented 10 months ago

I have installed the module, and yet importing causal_conv1d, I get python test.py Traceback (most recent call last): File "D:\Downloads\mambafinal\mamba\test.py", line 7, in import causal_conv1d File "D:\condainstall\envs\mambafinal\lib\site-packages\causal_conv1d__init__.py", line 3, in from causal_conv1d.causal_conv1d_interface import causal_conv1d_fn, causal_conv1d_update File "D:\condainstall\envs\mambafinal\lib\site-packages\causal_conv1d\causal_conv1d_interface.py", line 7, in import causal_conv1d_cuda ModuleNotFoundError: No module named 'causal_conv1d_cuda'

apoorvkh commented 9 months ago

Hey @tridao,

Trying to install and run causal-conv1d (to use mamba-ssm).

My conda environment (on a Linux system) has Python 3.11, CUDA 11.8, PyTorch 2.2, and gcc/g++ 11.2.0. Accordingly, I am running pip install https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.1.1/causal_conv1d-1.1.1+cu118torch2.2cxx11abiFALSE-cp311-cp311-linux_x86_64.whl. (Not really sure what "abi" is, but tried this with both True and False).

Afterwards, I am trying "from causal_conv1d import causal_conv1d_fn" and get the following traceback. I have tried this on CPU, on a 3090 GPU, and an A100 GPU. Do you have any ideas what could be going wrong? Thanks!

  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.11/site-packages/causal_conv1d/__init__.py", line 3, in <module>
    from causal_conv1d.causal_conv1d_interface import causal_conv1d_fn, causal_conv1d_update
  File ".venv/lib/python3.11/site-packages/causal_conv1d/causal_conv1d_interface.py", line 7, in <module>
    import causal_conv1d_cuda
ImportError: .venv/lib/python3.11/site-packages/causal_conv1d_cuda.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZN2at4_ops10zeros_like4callERKNS_6TensorEN3c108optionalINS5_10ScalarTypeEEENS6_INS5_6LayoutEEENS6_INS5_6DeviceEEENS6_IbEENS6_INS5_12MemoryFormatEEE
tridao commented 9 months ago

Try compiling from source?

apoorvkh commented 9 months ago

Compiling from source did work!

I think both of these worked for us.

MAX_JOBS=2 CAUSAL_CONV1D_FORCE_BUILD="TRUE" python setup.py bdist_wheel --dist-dir=dist
python setup.py install
CAUSAL_CONV1D_FORCE_BUILD="TRUE" python setup.py build
python setup.py install

But using the pre-built wheels would be an easier to inherit in our project as a dependency. Do you know why the pre-build wheel could have had that issue? Is it possible to force the build when adding this repo as a pip requirement?

Thanks!

tridao commented 9 months ago

I don't have bandwidth to investigate at the moment. If you figure out sth lmk.

Wongboo commented 9 months ago

I think this question is fixed through the release today, how about add python 3.12 to the CI?

tridao commented 9 months ago

I think this question is fixed through the release today, how about add python 3.12 to the CI?

You can send a PR if you'd like

apoorvkh commented 9 months ago

Thanks for the fix! The new build (1.1.3) solves my issue above 👍

Alittlemole commented 2 months ago

@takeraparterer hi how did u solve this problem?

takeraparterer commented 2 months ago

@Alittlemole I don't think I did?

Alittlemole commented 2 months ago

so how did u run ur code with this bug? @takeraparterer

apoorvkh commented 2 months ago

It worked on my end. If I recall correctly, the pre-built wheel I had been using was not built for the exact CUDA or PyTorch version I had been using. Using a newer release of causal-conv1d fixed it.

I think you can either pick a build from the latest release (based on the versions of your other dependencies) and e.g. pip install https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.4.0/causal_conv1d-1.4.0+cu118torch2.0cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

or you can build it yourself on your own system via

pip install causal-conv1d --no-build-isolation

takeraparterer commented 2 months ago

@Alittlemole I don't exactly remember what this was about, and I don't recall ever successfully running this