C4W4: Assignment 1, "channels_last" only runs on GPU?


I am trying to run the C4W4: Assignment 1 Face Recognition on my local machine. However, I get an error with “channels_last” whenever I get to:

database["danielle"] = img_to_encoding("images/danielle.png", FRmodel)

Which then calls img_to_encoding() from the file fr_utils.py:

File “fr_utils.py”, line 215, in img_to_encoding
embedding = model.predict_on_batch(x_train)

And the error:

InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU
[[node FaceRecoModel/max_pooling2d_21/MaxPool (defined at /home/dendaxon/Documents/dev/skinks/nn/fr_utils.py:215) ]] [Op:__inference_predict_function_9082]

Function call stack:

I assume this is saying that we can have channels_last only with GPU?
If this is the case, is there a possible workaround to run the code on CPU?
Many thanks

Maybe this will help you:

Thank you very much for your answer, it’s good. However, my question was a bit more generic (also, I’m running NVIDIA) - whenever I try to run the model anywhere outside the Coursera platform, whether that’s locally or at Google Colab - it always gives this channels_last running only on GPU error.

However, in Tensorflow 1.0, it runs without any problems.

So in summary, the thing I don’t understand is: in TF 2.0, is this model only possible to be run on GPU?

Many thanks again :slight_smile:

@zzeck I did some snooping after reading your earlier post. Can’t claim to have understood all the details, but I found a long technical report discussing the difference in memory layout and optimization between GPU and CPU was what lead to the difference on Intel architecture. Not sure this is the exact one I read, but it does have some relevant discussion. Look for the section:

Data Layout

Recommended settings → data_format = NHWC