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

Update saver.py #20985

Merged
merged 1 commit into from
Jul 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions tensorflow/python/training/saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,10 @@ def _read_variable_closure(v):
def f():
with ops.device(v.device):
x = v.read_value()
# To allow variables placed on non-CPU devices to be checkpointed,
# we copy them to CPU on the same machine first.
device_spec = pydev.DeviceSpec().parse_from_string(v.device)
device_spec.merge_from(
pydev.DeviceSpec().parse_from_string("/device:CPU:0"))
with ops.device(device_spec.to_string()):
return array_ops.identity(x)
# To allow variables placed on non-CPU devices to be checkpointed,
# we copy them to CPU on the same machine first.
with ops.device("/device:CPU:0"):
return array_ops.identity(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to undo the intent of the original code, because it doesn't ensure that it is copied to CPU on the same machine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I am not sure why we are reverting the fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agarwal-ashish It does the same job as your fix. Because it is under the context of v.device, it will just replace the last part of device to 'device:CPU:0'.
e.g.
'/job:ps/task:1/device:CPU:1' -->'/job:ps/task:1/device:CPU:0'
'/job:ps/task:1/device:GPU:0' -->'/job:ps/task:1/device:CPU:0'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's correct... I missed the indentation change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that too and hence bounced it to the authors. Thanks for pointing out, @jackonan

return f

self.handle_op = var.handle
Expand Down