NVIDIA / NVIDIA/apex

RuntimeError: Function 'MmBackward' returned nan values in its 0th output.

Open
#440 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Description

I use
model, optimizer = amp.initialize(model, optimizer, opt_level='O1' )
and my loss backwards is handled by
with amp.scale_loss(loss, optimizer) as scaled_loss: scaled_loss.backward()
Things work well without amp.initialize, so I guess the problem is triggered by the mix precision... Can anyone give me a hint for solving such problem? Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure around amp.initialize with opt_level='O1' and the amp.scale_loss(loss, optimizer) backward path. Compare the failing mixed-precision run with the working run without AMP, then narrow down the operation producing the MmBackward NaN; done means a reproducible diagnosis and a confirmed fix or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.