Skip to content

Linking issue "Failed to dlopen libcutensornet", and the potential solution. #136

Description

@liweintu

After a fresh installation from poetry, when running pytest test_cuquantum_cutensor_backend.py, I encountered this error below.

FAILED test_cuquantum_cutensor_backend.py::test_eval[1] - RuntimeError: Failed to dlopen libcutensornet

After debugging using Gemini, the error seems to be related to shared libraries folders not being able to be located, which was due to installation via pip/poetry, as explained below.

The error you're encountering happens because cuquantum-python-cu12 and its related dependencies (like cutensor, cusolver, etc.) are installed via pip/poetry. When installed this way on Linux, their shared libraries (.so files) are placed in separate folders inside your Python environment's site-packages directory. The system's dynamic linker cannot automatically locate them, resulting in the Failed to dlopen libcutensornet runtime error as it fails to resolve inner dependencies like libcusolver.so.11.

The following fix works, that is, adding these folders to LD_LIBBRARY_PATH (recommended by Gemini too), after which, the error goes away.

# 1. Define the base path for your environment's site-packages
export SITE_PACKAGES="/home/liwei/miniforge3/envs/qibotn_cuda12_py312/lib/python3.12/site-packages"

# 2. Add the NVIDIA and cuQuantum library paths to LD_LIBRARY_PATH
export LD_LIBRARY_PATH="$SITE_PACKAGES/nvidia/cublas/lib:$SITE_PACKAGES/nvidia/cusolver/lib:$SITE_PACKAGES/nvidia/cusparse/lib:$SITE_PACKAGES/nvidia/cuda_nvrtc/lib:$SITE_PACKAGES/nvidia/cuda_runtime/lib:$SITE_PACKAGES/nvidia/nccl/lib:$SITE_PACKAGES/cuquantum/lib:$SITE_PACKAGES/cutensor/lib:$LD_LIBRARY_PATH"

# 3. Run your tests again
pytest test_cuquantum_cutensor_backend.py

Maybe we should update LD_LIBBRARY_PATH too according to the installation folders?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions