Skip to content

Fix numba-cuda CPU import crash after base image upgrade#1548

Merged
stevemessick merged 5 commits intomainfrom
fix-numba-cuda-cpu-import
Apr 30, 2026
Merged

Fix numba-cuda CPU import crash after base image upgrade#1548
stevemessick merged 5 commits intomainfrom
fix-numba-cuda-cpu-import

Conversation

@stevemessick
Copy link
Copy Markdown
Contributor

Problem

After merging #1547 (Colab base image upgrade), the main branch CI is failing on the Test CPU Image stage (build #1924). The upgraded numba-cuda v0.30.0 now depends on cuda-bindings which requires libcudart.so at import time — this crashes on the CPU image where no CUDA runtime is installed.

Two tests fail:

  • test_numbafrom numba import cuda at module level triggers the crash
  • test_tsfreshtsfreshstumpyfrom numba import cuda → same crash
cuda.pathfinder._dynamic_libs.load_dl_common.DynamicLibNotFoundError:
Failure finding "libcudart.so": No such file: libcudart.so*

Fix

Dockerfile.tmpl

  • Keep numba upgrade for both CPU and GPU images (needed for NumPy 2.4)
  • Move numba-cuda install into the GPU-only section ({{ if eq .Accelerator "gpu" }})

test_numba.py

  • Move from numba import cuda from module-level into the @gpu_test method (lazy import)

test_tsfresh.py

  • Guard the tsfresh import with try/except and skip the test if it fails on CPU

b/485275559

numba-cuda v0.30.0 depends on cuda-bindings which requires libcudart.so
at import time. This crashes on the CPU image where no CUDA runtime is
installed. Move numba-cuda install into the GPU-only section while
keeping the numba upgrade for both CPU and GPU.

b/485275559
Move 'from numba import cuda' from module level into the @gpu_test
method. numba-cuda v0.30.0 requires libcudart.so at import time,
which is not available on the CPU image.
tsfresh -> stumpy -> numba.cuda, which requires libcudart.so.
Guard the import so the test is skipped on CPU rather than crashing.
@stevemessick stevemessick requested a review from rosbo April 30, 2026 16:48
Comment thread tests/test_tsfresh.py Outdated

from tsfresh import extract_features
try:
from tsfresh import extract_features
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tsfresh should also work without a GPU.

Instead of just skipping tsfresh tests on CPU, uninstall numba-cuda
from the Colab base image on CPU builds. This lets tsfresh/stumpy
work correctly on CPU without CUDA dependencies.

On GPU, numba-cuda is upgraded to v0.30.0 for NumPy 2.4 support.
Now that numba-cuda is uninstalled on the CPU image, tsfresh/stumpy
imports work without requiring libcudart.so. No need for the skip guard.
@stevemessick
Copy link
Copy Markdown
Contributor Author

Good point — fixed. Instead of skipping the tsfresh test on CPU, I now uninstall numba-cuda from the Colab base image on CPU builds (new {{ else }} clause in the Dockerfile template). This way tsfresh/stumpy import correctly on CPU without the cuda-bindings dependency that requires libcudart.so, and the test runs normally.

On GPU, numba-cuda is still upgraded to v0.30.0 for the np.trapz fix.

@stevemessick stevemessick requested a review from rosbo April 30, 2026 17:22
Copy link
Copy Markdown
Contributor

@rosbo rosbo left a comment

Choose a reason for hiding this comment

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

LGTM assuming build & tests are passing.

@stevemessick stevemessick merged commit 1c8da17 into main Apr 30, 2026
3 of 4 checks passed
@stevemessick stevemessick deleted the fix-numba-cuda-cpu-import branch April 30, 2026 17:29
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