Commit 6fae503
committed
fix: Allow loading CUDA-saved models on CPU-only machines
When a CEBRA checkpoint was saved on a CUDA device but is loaded on a
machine without CUDA available, it now gracefully falls back to CPU
instead of crashing with RuntimeError.
Changes:
- Add _resolve_checkpoint_device() helper to handle device resolution
- Update _load_cebra_with_sklearn_backend() to use resolved device
- Handle both string and torch.device types, including cuda:0 variants
- Update model device attributes after resolution
Fixes: Loading model saved with device='cuda' on CPU-only machine1 parent acd63c7 commit 6fae503
2 files changed
Lines changed: 47 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
337 | 363 | | |
338 | 364 | | |
339 | 365 | | |
| |||
357 | 383 | | |
358 | 384 | | |
359 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
360 | 391 | | |
361 | 392 | | |
362 | 393 | | |
363 | 394 | | |
364 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
365 | 404 | | |
366 | 405 | | |
367 | 406 | | |
| |||
375 | 414 | | |
376 | 415 | | |
377 | 416 | | |
378 | | - | |
| 417 | + | |
379 | 418 | | |
380 | 419 | | |
381 | 420 | | |
| |||
385 | 424 | | |
386 | 425 | | |
387 | 426 | | |
388 | | - | |
| 427 | + | |
389 | 428 | | |
390 | 429 | | |
391 | | - | |
| 430 | + | |
392 | 431 | | |
393 | 432 | | |
394 | 433 | | |
| |||
404 | 443 | | |
405 | 444 | | |
406 | 445 | | |
407 | | - | |
| 446 | + | |
408 | 447 | | |
409 | 448 | | |
410 | 449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1142 | 1142 | | |
1143 | 1143 | | |
1144 | 1144 | | |
1145 | | - | |
| 1145 | + | |
| 1146 | + | |
1146 | 1147 | | |
1147 | 1148 | | |
1148 | 1149 | | |
| |||
1171 | 1172 | | |
1172 | 1173 | | |
1173 | 1174 | | |
1174 | | - | |
| 1175 | + | |
| 1176 | + | |
1175 | 1177 | | |
1176 | 1178 | | |
1177 | 1179 | | |
| |||
0 commit comments