Loss becomes NaN when training with multiple GPUs
I used JAX to fine-tune π0.5 on the LIBERO dataset with LoRA. When I trained with multiple GPUs, I got
Step 0: grad_norm=nan, loss=nan, param_norm=nan
But when I switched to single-GPU training, everything worked normally:
Step 0: grad_norm=0.5642, loss=0.0942, param_norm=1803.7705
Why does this happen, and how can I fix the issue with multi-GPU training?
Hi @Elycyx , same problem encountered. But my situation is a little diffferent:
For the same code , in the same terminal, i run the same training command, sometimes the loss is nan, but sometimes the loss is normal.
Step 0: grad_norm=4.2683, loss=0.6440, param_norm=1802.3864 Step 100: grad_norm=2.2463, loss=0.2684, param_norm=1802.3861
Step 0: grad_norm=nan, loss=nan, param_norm=nan
This is quite wired.
Besides, i am using multi GPU
I've also encountered the same problem. The official Libero dataset works fine, but when I switch to a new dataset, I get NaN values. Sometimes this happens after only a few dozen steps, and sometimes it takes thousands of steps before it occurs. I suspect this might be related to the dataset, especially the image (padding or sth).
Does anyone have any idea? I've also encountered the same problem. I’m training on a custom dataset, and after a few steps, both the loss and the model outputs become NaN.
I'm encountering the same issue. When I use a single GPU to train on my custom dataset, the training behavior is perfectly stable. However, when I switch to a 4x A6000 setup, the process becomes highly unstable and non-deterministic. Sometimes the loss becomes NaN right at Step 0, sometimes it spikes by an order of magnitude after just a few steps, and occasionally it appears to train normally. Has anyone found a reliable workaround or identified the root cause for this?
Check memory and resources. Ensure that the GPU has sufficient memory. Insufficient memory can sometimes cause NaN values. I solve it by increase "--fsdp-devices" to lower the memory usage and then "loss=NaN" disappears.