Python 使用数据集API时,tensorflow出现设备放置错误>;=1.11

Python 使用数据集API时,tensorflow出现设备放置错误>;=1.11,python,tensorflow,tensorflow-datasets,Python,Tensorflow,Tensorflow Datasets,我的脚本使用dataset API实现输入管道。当我使用tensorflow 1.10时,一切正常,但当我升级到tensorflow 1.11或1.12时。我在培训开始时收到以下错误消息: 试图在设备“/job:localhost/replica:0/task:0/device:GPU:0”上从设备上定义的句柄“/job:localhost/replica:0/task:0/device:CPU:0”上创建迭代器 下面是我的一段代码: def build_all_dataset(self):

我的脚本使用dataset API实现输入管道。当我使用tensorflow 1.10时,一切正常,但当我升级到tensorflow 1.11或1.12时。我在培训开始时收到以下错误消息:

试图在设备“/job:localhost/replica:0/task:0/device:GPU:0”上从设备上定义的句柄“/job:localhost/replica:0/task:0/device:CPU:0”上创建迭代器

下面是我的一段代码:

def build_all_dataset(self):
    self.build_dataset(ROUTE_TRAIN)
    self.build_dataset(ROUTE_VALIDATION)
    self.build_dataset(ROUTE_TEST)

def build_dataset(self, p_route):
    # Create dataset instance.
    # ......
    # ......

    self.dataset[p_route] = dataset
    self.iterators[p_route] = dataset.make_initializable_iterator()
    self.handles[p_route] = (self.iterators[p_route].string_handle()).eval()

def build_model(self):
    with tf.device("/GPU:0"):
        # Build dataset for training/validation/test.
        self.build_all_dataset()
        self.ph_dataset_handle = tf.placeholder(tf.string, shape=[])
        iterator = tf.data.Iterator.from_string_handle(self.ph_dataset_handle, self.dataset[ROUTE_TRAIN].output_types,
                                                       self.dataset[ROUTE_TRAIN].output_shapes)

        xxx, xxx, xxx = iterator.get_next()
        # Build the following graph.
        # ......
        # ......

while True:
    try:
        session.run(xxx, {self.ph_dataset_handle: self.handles[ROUTE_TRAIN]})
    except tf.errors.OutOfRangeError:
        break
我检查了占位符“self.ph\u dataset\u handle”是否放在/GPU:0上,为什么tensorflow说“在设备上定义的句柄”/job:localhost/replica:0/task:0/device:CPU:0”

你能提供一些见解吗?谢谢