From 0c11bcb5f3443ce870f31f5ba013ae8bc375ad2d Mon Sep 17 00:00:00 2001 From: Jacker Date: Fri, 20 Jul 2018 10:09:16 +0800 Subject: [PATCH] Update saver.py Fix device placement of save_op for ResourceVariable. --- tensorflow/python/training/saver.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tensorflow/python/training/saver.py b/tensorflow/python/training/saver.py index 11510d9928e..60885e92926 100644 --- a/tensorflow/python/training/saver.py +++ b/tensorflow/python/training/saver.py @@ -126,13 +126,10 @@ class BaseSaverBuilder(object): 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) return f self.handle_op = var.handle