Skip to content

ci: set LD_LIBRARY_PATH in Docker images for correct cuBLAS detection#2468

Merged
yzh119 merged 2 commits intoflashinfer-ai:mainfrom
bkryu:ci_container_set_ld_lib_path
Feb 3, 2026
Merged

ci: set LD_LIBRARY_PATH in Docker images for correct cuBLAS detection#2468
yzh119 merged 2 commits intoflashinfer-ai:mainfrom
bkryu:ci_container_set_ld_lib_path

Conversation

@bkryu
Copy link
Collaborator

@bkryu bkryu commented Feb 2, 2026

📌 Description

Summary

  • Add LD_LIBRARY_PATH to Docker images to ensure pip-installed nvidia-cublas takes precedence over system libraries
  • Fixes issues where incorrect cuBLAS versions could be loaded at runtime

Example of what happens without prepending the path to LD_LIBRARY_PATH in our cu130 containers:

$ docker run --gpus all -it flashinfer/flashinfer-ci-cu130:20260131-a52eff1
Unable to find image 'flashinfer/flashinfer-ci-cu130:20260131-a52eff1' locally
20260131-a52eff1: Pulling from flashinfer/flashinfer-ci-cu130
Digest: sha256:582aeb35289cf804735a31727abe8ff37ae722fe6c7bd7fb8ddf50654429ff7a
Status: Downloaded newer image for flashinfer/flashinfer-ci-cu130:20260131-a52eff1

==========
== CUDA ==
==========

CUDA Version 13.0.1

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

(py312) root@fdac9b9cd61e:/workspace# python -c "import torch; print(torch.matmul(torch.randn(128,128,device='cuda'), torch.randn(128,128,device='cuda')))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
(py312) root@fdac9b9cd61e:/workspace# export LD_LIBRARY_PATH=/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cu13/lib/:$LD_LIBRARY_PATH
(py312) root@fdac9b9cd61e:/workspace# python -c "import torch; print(torch.matmul(torch.randn(128,128,device='cuda'), torch.randn(128,128,device='cuda')))"
tensor([[ 14.9044,  14.3420,  26.0861,  ..., -10.4334,  -4.5352,   4.2331],
        [  1.9701,  13.6111,   1.0954,  ...,   3.0715,  -2.9266,   7.8847],
        [  6.5089,  -7.4811, -12.6226,  ...,  -5.3695,  -4.4557, -22.4567],
        ...,
        [-12.0462,  -2.0045,  15.7295,  ...,  -4.5688,  22.5680, -11.9852],
        [ -0.4228,  10.2761,   0.1951,  ...,  16.5192,  12.7168,   0.9931],
        [ -0.2800,  -5.7174,  -2.9644,  ...,   1.8484, -10.0042,  -7.7290]],
       device='cuda:0')

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

Summary by CodeRabbit

  • Chores
    • Updated Docker build configurations for CUDA 12.6, 12.8, 12.9, and 13.0 to set runtime library precedence so conda-installed NVIDIA cuBLAS libraries are favored over system libraries.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bkryu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves critical runtime issues within the Docker CI images by ensuring that the correct pip-installed nvidia-cublas libraries are prioritized over system libraries. By explicitly setting the LD_LIBRARY_PATH in the Docker environments, the system now consistently loads the intended cuBLAS version, leading to stable and predictable execution of CUDA-dependent operations.

Highlights

  • LD_LIBRARY_PATH Configuration: Modified Dockerfiles (Dockerfile.cu126, Dockerfile.cu128, Dockerfile.cu129, Dockerfile.cu130) to prepend the path to pip-installed nvidia-cublas libraries to LD_LIBRARY_PATH. This ensures that the correct cuBLAS version is loaded at runtime, preventing potential conflicts with system libraries.
  • Fix for cuBLAS Runtime Errors: This change directly addresses and resolves RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE issues observed when running CUDA-dependent operations within the Docker images, which occurred due to incorrect cuBLAS versions being loaded.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docker/Dockerfile.cu126
    • Added ENV LD_LIBRARY_PATH="/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cublas/lib/:$LD_LIBRARY_PATH" to ensure pip-installed nvidia-cublas takes precedence.
  • docker/Dockerfile.cu128
    • Added ENV LD_LIBRARY_PATH="/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cublas/lib/:$LD_LIBRARY_PATH" to ensure pip-installed nvidia-cublas takes precedence.
  • docker/Dockerfile.cu129
    • Added ENV LD_LIBRARY_PATH="/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cublas/lib/:$LD_LIBRARY_PATH" to ensure pip-installed nvidia-cublas takes precedence.
  • docker/Dockerfile.cu130
    • Added ENV LD_LIBRARY_PATH="/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cu13/lib/:$LD_LIBRARY_PATH" to ensure pip-installed nvidia-cu13 takes precedence.
Activity
  • The author, bkryu, has provided a detailed description of the problem, including a reproducible example demonstrating the RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE and how setting LD_LIBRARY_PATH resolves it.
  • The pull request includes a standard checklist for pre-commit checks and tests, indicating the author's intention to ensure code quality and functionality.
  • No specific reviewer comments or interactions are available in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Four CUDA Dockerfiles (12.6, 12.8, 12.9, 13.0) add ENV entries that prepend conda-installed NVIDIA cuBLAS library paths to LD_LIBRARY_PATH to prefer conda-provided cuBLAS over system libraries at runtime.

Changes

Cohort / File(s) Summary
CUDA Dockerfile Library Path Configuration
docker/Dockerfile.cu126, docker/Dockerfile.cu128, docker/Dockerfile.cu129, docker/Dockerfile.cu130
Added ENV LD_LIBRARY_PATH=... lines that prepend the conda py312 environment nvidia-cublas/cublas library directories to LD_LIBRARY_PATH in each Dockerfile (similar +3 lines per file).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • yzh119

Poem

🐰 In Docker nests I nibble and leap,
I tuck cuBLAS first for runtime to keep,
Conda paths snug, no system will peep,
Rabbity builds now run cozy and steep. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: setting LD_LIBRARY_PATH in Docker images for cuBLAS detection.
Description check ✅ Passed The description provides a clear summary of changes and includes a practical reproduction example demonstrating the issue and fix, though the Related Issues section is empty.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly sets the LD_LIBRARY_PATH in the Docker images to ensure the pip-installed nvidia-cublas library is prioritized, which resolves runtime errors with incorrect cuBLAS versions. The changes are applied consistently across Dockerfiles for different CUDA versions. My review includes a suggestion to improve the maintainability of these Dockerfiles by using ARG variables to avoid hardcoding Python versions and conda environment names. This will make future updates easier and less error-prone.

@bkryu bkryu requested a review from yzh119 February 3, 2026 00:18
@bkryu bkryu self-assigned this Feb 3, 2026
Copy link
Collaborator

@yzh119 yzh119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we need to keep in mind about updating these environments variables in the future though (e.g. if we update to py313 or new cuda docker containers).

@yzh119 yzh119 merged commit 9b5901e into flashinfer-ai:main Feb 3, 2026
29 checks passed
@bkryu bkryu deleted the ci_container_set_ld_lib_path branch February 3, 2026 16:58
raayandhar pushed a commit to raayandhar/flashinfer that referenced this pull request Feb 5, 2026
…flashinfer-ai#2468)

<!-- .github/pull_request_template.md -->

## 📌 Description


Summary
* Add `LD_LIBRARY_PATH` to Docker images to ensure pip-installed
`nvidia-cublas` takes precedence over system libraries
* Fixes issues where incorrect cuBLAS versions could be loaded at
runtime

Example of what happens without prepending the path to `LD_LIBRARY_PATH`
in our cu130 containers:
```
$ docker run --gpus all -it flashinfer/flashinfer-ci-cu130:20260131-a52eff1
Unable to find image 'flashinfer/flashinfer-ci-cu130:20260131-a52eff1' locally
20260131-a52eff1: Pulling from flashinfer/flashinfer-ci-cu130
Digest: sha256:582aeb35289cf804735a31727abe8ff37ae722fe6c7bd7fb8ddf50654429ff7a
Status: Downloaded newer image for flashinfer/flashinfer-ci-cu130:20260131-a52eff1

==========
== CUDA ==
==========

CUDA Version 13.0.1

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

(py312) root@fdac9b9cd61e:/workspace# python -c "import torch; print(torch.matmul(torch.randn(128,128,device='cuda'), torch.randn(128,128,device='cuda')))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
(py312) root@fdac9b9cd61e:/workspace# export LD_LIBRARY_PATH=/opt/conda/envs/py312/lib/python3.12/site-packages/nvidia/cu13/lib/:$LD_LIBRARY_PATH
(py312) root@fdac9b9cd61e:/workspace# python -c "import torch; print(torch.matmul(torch.randn(128,128,device='cuda'), torch.randn(128,128,device='cuda')))"
tensor([[ 14.9044,  14.3420,  26.0861,  ..., -10.4334,  -4.5352,   4.2331],
        [  1.9701,  13.6111,   1.0954,  ...,   3.0715,  -2.9266,   7.8847],
        [  6.5089,  -7.4811, -12.6226,  ...,  -5.3695,  -4.4557, -22.4567],
        ...,
        [-12.0462,  -2.0045,  15.7295,  ...,  -4.5688,  22.5680, -11.9852],
        [ -0.4228,  10.2761,   0.1951,  ...,  16.5192,  12.7168,   0.9931],
        [ -0.2800,  -5.7174,  -2.9644,  ...,   1.8484, -10.0042,  -7.7290]],
       device='cuda:0')
```

<!-- What does this PR do? Briefly describe the changes and why they’re
needed. -->

## 🔍 Related Issues

<!-- Link any related issues here -->

## 🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull
request, please make sure the following items are complete.

### ✅ Pre-commit Checks

- [ ] I have installed `pre-commit` by running `pip install pre-commit`
(or used your preferred method).
- [ ] I have installed the hooks with `pre-commit install`.
- [ ] I have run the hooks manually with `pre-commit run --all-files`
and fixed any reported issues.

> If you are unsure about how to set up `pre-commit`, see [the
pre-commit documentation](https://pre-commit.com/).

## 🧪 Tests

- [ ] Tests have been added or updated as needed.
- [ ] All tests are passing (`unittest`, etc.).

## Reviewer Notes

<!-- Optional: anything you'd like reviewers to focus on, concerns, etc.
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Updated Docker build configurations for CUDA 12.6, 12.8, 12.9, and
13.0 to set runtime library precedence so conda-installed NVIDIA cuBLAS
libraries are favored over system libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants