RuntimeError: expected scalar type Half but found Float
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.5k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
Hello, I am trying to use amp to have mixed precision training for my model. I am implementing a multi-task learning algorithm, so my loss is a summation of loss_a and loss_b, which I then back-propagate. When doing so and following amp usage instructions I get:
RuntimeError: expected scalar type Half but found Float
I also tried, back-propagating one loss at the time, while retaining the graph, following your instructions for multiple losses. I get the same error.
In the previous cases, I didn't use model.half(). When I did, my losses started becoming NaN.
Do you have any suggestions on how to proceed?
Thanks in advance!
VglsD
*Edit: I should also note that my network has Batch Normalization Layers
Environment: Miniconda, Python 3.7, Cuda 10, PyTorch 1.0, apex master branch
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names no repository file, test, or minimal reproduction. Start by reproducing the AMP multi-task loss case with PyTorch 1.0, CUDA 10, Batch Normalization, and the stated Apex environment; compare summed versus separately back-propagated losses and confirm whether the Half/Float error or NaNs remain. Done means a confirmed fix or a documented, reproducible explanation and guidance.
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
- 25/100