Input Pipeline for Tensorflow on GPU The tensorflow example CIFAR10 uses input pipelines to load data from the disk to a queue. I would like to implement this for my own models, but I run into an error that I can't fix somehow. My minimal example looks like the following (taken from the tutorials: 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, ...)


This is basically what is done in CIFAR10, just with a csv. The script runs with MY_DEVICE = '/cpu:0', but when I try to run it on the GPU with MY_DEVICE = '/gpu:0' I get the following error:

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"]()]]


Can I not use input pipelines on GPUs? Isn't this what is done in CIFAR10?
Solution to my question: If you run a tensorflow session you can choose if the placement of nodes on the different devices is hard or soft coded. In the specific case of CIFAR10 this means:


The Queues be placed on the GPU and that's why the error popped up, but:
If you turn on soft placement it works. This means, that even though the placement on the GPU of several parts of the model can't be done, Tensorflow solves this problem automaticly by placing them somewhere else
I don't actually know where the nodes get placed. I guess on the CPU, but I'm not sure. In tensorboard the color of the input pipeline nodes claims a placement on the GPU. Very confusing!


The soft placement can be done by starting the session like this:

sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True))


I found this on the following tutorial page: https://www.tensorflow.org/tutorials/using_gpu