C2_W4_Lab_3_Images: Question on tf.device context manager

I wanted to know more about what the with tf.device("/cpu:0") context manger is doing in the preprocessing_fn shown below. I think that this line is forcing the preprocessing_fn to run on the first cpu, but I don’t really know why we need to specify that.

I tried removing the context, and I’m unsure if it made any difference.

Any additional insight someone can share about the reason for this context manager would be great! I haven’t seen it in any of the previous labs.

def preprocessing_fn(inputs):
    # Convert the raw image and labels to a float array and
    # one-hot encoded labels, respectively.
    with tf.device("/cpu:0"):
        outputs = {

Hello @dzubke,

this is tight with training models concurently (distributed trainig) .
with tf.device('/cpu:0'): you tells Keras to use the CPU. If you want to force the GPU you can pass with tf.device('/gpu:0'):