You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Loading a model saved on CUDA fails on CPU-only machines #295
CEBRA.load(...) fails with RuntimeError: No CUDA GPUs are available when loading a checkpoint that was saved on a CUDA device from an environment where no GPU is available (e.g. CPU-only machine or notebook, or PyTorch built without CUDA).
Environment
OS: macOS 15.2 (Darwin 25.2.0, arm64)
CEBRA version: 0.6.0
PyTorch version: 2.10.0
Device: CPU-only (CUDA not available)
Steps to Reproduce
Train and save a CEBRA model on a machine with CUDA:
The checkpoint stores the training device in state['device_'] (e.g., 'cuda' or 'cuda:0')
_load_cebra_with_sklearn_backend() calls .to(state['device_']) on model, criterion, and solver
This triggers PyTorch CUDA initialization; if no GPU available, it raises the error
map_location=torch.device('cpu') in torch.load() only affects tensor loading, not subsequent .to() calls
Expected Behavior
Loading should succeed on CPU-only environments: the model should gracefully fall back to CPU when CUDA is not available, regardless of the device used when saving.
Related
A fix for this issue has been prepared and will be submitted as a PR shortly.
A fix for this issue has been implemented in PR #296.
Summary of the Fix
The fix adds a _resolve_checkpoint_device() helper function that detects when a checkpoint was saved on CUDA but CUDA is not available at load time, and automatically falls back to CPU.
Activity
robosimon commentedon Feb 11, 2026
Fix Available
A fix for this issue has been implemented in PR #296.
Summary of the Fix
The fix adds a
_resolve_checkpoint_device()helper function that detects when a checkpoint was saved on CUDA but CUDA is not available at load time, and automatically falls back to CPU.Changes
Test Coverage
monkeypatchto mock CPU-only environmentsPlease review the PR when ready.
stes commentedon Feb 11, 2026
CEBRA follows torch; loading with
map_location = "cpu"should do the trick. We could potentially highlight this in the error message.