Skip to content

Undefined symbol in C++ extension when using Python 3.11 and PyTorch-based C++/CUDA module (selective_scan_cuda) #137071

@atulegenova

Description

@atulegenova

Bug report

Bug description:

Describe the bug
While importing a compiled PyTorch CUDA extension (selective_scan_cuda.cpython-311-x86_64-linux-gnu.so from the mamba-ssm library), Python 3.11 raises an ImportError with an unresolved C++ symbol.

This happens only under Python 3.11, while the same library works with Python 3.10.


Error message
ImportError: /usr/local/lib/python3.11/dist-packages/selective_scan_cuda.cpython-311-x86_64-linux-gnu.so:
undefined symbol: _ZN3c107WarningC1ESt7variantIJNS0_11UserWarningENS0_18DeprecationWarningEEERKNS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb


Expected behavior
The .so file should load if built correctly against Python 3.11-compatible headers and libraries. At the very least, the Python interpreter should offer better diagnostics if a symbol version mismatch occurs due to Python or ABI changes.


To Reproduce

# In Python 3.11 environment with torch and mamba-ssm installed
from mamba_ssm import Mamba  # raises ImportError


### CPython versions tested on:

3.11

### Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions