tensorflow示例 CIFAR10使用输入管道将数据从磁盘加载到队列。我想为我自己的模型实现这个,但我遇到了一个我无法以某种方式修复的错误。我的最小示例如下所示(取自教程:https ://www.tensorflow.org/programmers_guide/reading_data ):
def read_sample_of_csv(filename_queue):
# Define Reader
reader = tf.TextLineReader()
key,value = reader.read(filename_queue)
# Decode CSV
record_defaults = [[1.],[1.],[1.],[1.],[1.],[1.],[1.],[1.],[1.],[1.]]
col0, *col = tf.decode_csv(value, record_defaults=record_defaults)
features = tf.stack([*col])
reference = col0
# Return
return features, reference
def input_pipeline(filenames, batch_size, ...):
# Reader for samples
slipangle_filename_queue = tf.train.string_input_producer(filenames, shuffle=shuffle)
features, reference = read_sample_of_csv(slipangle_filename_queue)
# Batch samples
capacity = min_after_dequeue + (num_threads+3) * batch_size
feature_batch, reference_batch = tf.train.shuffle_batch([features,reference], batch_size=batch_size)
# Return
return feature_batch, reference_batch
with tf.device(MY_DEVICE):
feature_batch, ref_batch = input_pipeline(filenames, batch_size, ...)
这基本上是 CIFAR10 中所做的,只是使用 csv。该脚本使用 MY_DEVICE = '/cpu:0' 运行,但是当我尝试使用 MY_DEVICE = '/gpu:0' 在 GPU 上运行它时,我收到以下错误:
InvalidArgumentError (see above for traceback): Cannot assign a device to node 'shuffle_batch/random_shuffle_queue': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and devices:
QueueEnqueue: CPU
QueueSize: CPU
QueueClose: CPU
QueueDequeueMany: CPU
RandomShuffleQueue: CPU
[[Node: shuffle_batch/random_shuffle_queue = RandomShuffleQueue[capacity=1500, component_types=[DT_FLOAT, DT_FLOAT], container="", min_after_dequeue=1000, seed=0, seed2=0, shapes=[[9], []], shared_name="", _device="/device:GPU:0"]()]]
我不能在 GPU 上使用输入管道吗?这不是 CIFAR10 所做的吗?