Menu

I resumed training with fewer GPUs than I started with. It crashed. Here's why.
πŸ“°

I resumed training with fewer GPUs than I started with. It crashed. Here's why.

DEV Community: pytorchΒ·Hassaan ToleΒ·10 days ago
#HKcANvMb
#devtopytorch#devto#dev#state#efficio
Long article (451 words) β€” no AI summary yet.
Reading 0:00
15s threshold

I was testing cross-platform resume for Efficio (an open-source PyTorch training library): start a run on Kaggle's 2x T4 GPUs, finish it on Colab's single T4. Training resumed fine, right up until it tried to restore the random number generator state. Then it crashed with an IndexError.

Here's what was going on, and the fix.

The setup

Efficio checkpoints save CUDA's RNG state so a resumed run is numerically consistent, not just "roughly where you left off." That means saving torch.cuda.get_rng_state_all() , which returns one RNG state per GPU that was active when the checkpoint was written.

The restore side used torch.cuda.set_rng_state_all() to put them back. That function expects a list with exactly as many entries as GPUs available right now . My checkpoint had 2 entries (from Kaggle's 2 GPUs). Colab had 1. Index out of range.

Why this is an easy bug to miss

Most resume testing happens on the same machine, or at least the same GPU count.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.