Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] cpu loss in actions #308

Merged
merged 2 commits into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/start_here/simplest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import nemo

nf = nemo.core.NeuralModuleFactory()

# To use CPU-only do:
# from nemo.core import DeviceType
# nf = nemo.core.NeuralModuleFactory(placement=DeviceType.CPU)
Expand Down
6 changes: 5 additions & 1 deletion nemo/backends/pytorch/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,11 @@ def train(
final_loss.backward(bps_scale.to(final_loss.get_device()))
# single device (CPU or GPU)
else:
final_loss.backward(bps_scale.to(final_loss.get_device()))
# Fix (workaround?) enabling to backpropagate gradiens on CPUs.
if final_loss.get_device() < 0:
final_loss.backward(bps_scale.to(final_loss))
tkornuta-nvidia marked this conversation as resolved.
Show resolved Hide resolved
else:
final_loss.backward(bps_scale.to(final_loss.get_device()))

batch_counter += 1

Expand Down