Skip to content

fix(cuda): define xp when cupy is installed but CUDA is unavailable#279

Merged
JoOkuma merged 1 commit into
mainfrom
fix/cuda-xp-undefined-no-gpu
Jun 3, 2026
Merged

fix(cuda): define xp when cupy is installed but CUDA is unavailable#279
JoOkuma merged 1 commit into
mainfrom
fix/cuda-xp-undefined-no-gpu

Conversation

@JoOkuma

@JoOkuma JoOkuma commented Jun 3, 2026

Copy link
Copy Markdown
Member

Closes #277

When cupy is installed but cp.cuda.is_available() returns False (e.g. a CPU-only HPC node with cupy in the shared env), xp was never assigned, so from ultrack.utils.cuda import xp raised ImportError and broke any ultrack import.

Mirror the cupy-not-installed branch and set xp = np here too.

Reproduced the failure locally with a fake cupy module whose cuda.is_available() returns False; with the patch, xp is np and the downstream import in ultrack.utils.edge succeeds.

When cupy is installed but cp.cuda.is_available() returns False (e.g. on
a CPU-only HPC node with cupy in the shared environment), xp was left
undefined, so 'from ultrack.utils.cuda import xp' raised ImportError and
broke ultrack.utils.edge — and transitively any ultrack import.

Mirror the cupy-not-installed branch and set xp = np here too.

Closes #277
@JoOkuma JoOkuma merged commit 2f9a04a into main Jun 3, 2026
4 checks passed
@JoOkuma JoOkuma deleted the fix/cuda-xp-undefined-no-gpu branch June 3, 2026 18:07
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.

ImportError: cannot import name 'xp' from 'ultrack.utils.cuda' on CPU nodes when cupy is installed

1 participant