Closed pyotr777 closed 6 years ago
Unrelated to if this has been fixed. This is kind of a drive by comment. Sharing facts I believe I know for sure without research into what I do not know.
If you are using CPU-only I suggest building from source and using MKL. Here are some compelling stats. I realized building from source is a lot more work than downloading the binary. We are working on optimized builds. I know MKL supports this because I did the testing. Also you can just flip the data_format to NHWC and this works fine and for CPU is what you want unless using MKL.
You will also want to pass --device=cpu if you are using cpu only, due to soft placement it might just work anyway. There are also some MKL flags you could use if you use MKL those are in the link below as well.
NHWC was the data format of choice for CPU so many ops on CPU are not supported with the NCHW data_format. MKL (added by Intel and works fine on AMD, we tested) prefers NCHW and thus most operaitons are supported especially those related to CNNs as that is where they focused their time.
https://www.tensorflow.org/performance/performance_guide#tensorflow_with_intel_mkl_dnn
As @tfboyd stated, you must use --data_format=NHWC when running on the CPU. You should also use --device=cpu, as @tfboyd stated.
@zheng-xq, why do we use soft placement? It makes the error message very unclear. We should give a better error message if tf_cnn_benchmarks is run on a machine without a GPU and --device=cpu is not specified.
@tfboyd @reedwm
Thank you!
--device=cpu --data_format=NHWC
works for me.
I would suggest that --device=cpu --data_format=NHWC
should be the default when --num_gpus
option is 0 or is not there.
@reedwm I doubt XQ will answer here. :-) We should ask him though as having that on by default might be more trouble than the value (and I do not know the value for our script).
nonetheless of all the aforementioned methods worked with me. I have this error when trying to execute general CNN modal of 4 classes:
hist = model.fit(X_train, y_train, batch_size=16, epochs=num_epoch, verbose=1, validation_data=(X_test, y_test))
The is the displayed error: InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU [[{{node max_pooling2d_2/MaxPool}}]] I need any assistance to exceed this issue.
nonetheless of all the aforementioned methods worked with me. I have this error when trying to execute general CNN modal of 4 classes:
Training
hist = model.fit(X_train, y_train, batch_size=16, epochs=num_epoch, verbose=1, validation_data=(X_test, y_test))
The is the displayed error: InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU [[{{node max_pooling2d_2/MaxPool}}]] I need any assistance to exceed this issue.
Did you ever end up solving this issue?
Unrelated to if this has been fixed. This is kind of a drive by comment. Sharing facts I believe I know for sure without research into what I do not know.
If you are using CPU-only I suggest building from source and using MKL. Here are some compelling stats. I realized building from source is a lot more work than downloading the binary. We are working on optimized builds. I know MKL supports this because I did the testing. Also you can just flip the data_format to NHWC and this works fine and for CPU is what you want unless using MKL.
You will also want to pass --device=cpu if you are using cpu only, due to soft placement it might just work anyway. There are also some MKL flags you could use if you use MKL those are in the link below as well.
NHWC was the data format of choice for CPU so many ops on CPU are not supported with the NCHW data_format. MKL (added by Intel and works fine on AMD, we tested) prefers NCHW and thus most operaitons are supported especially those related to CNNs as that is where they focused their time.
https://www.tensorflow.org/performance/performance_guide#tensorflow_with_intel_mkl_dnn
excuse me, I meet the same error when inference with tensorflow1.10 C++ API, How should I solved this?
How to use --device=cpu --data_format=NHWC
in C++?
nonetheless of all the aforementioned methods worked with me. I have this error when trying to execute general CNN modal of 4 classes:
Training
hist = model.fit(X_train, y_train, batch_size=16, epochs=num_epoch, verbose=1, validation_data=(X_test, y_test))
The is the displayed error: InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU [[{{node max_pooling2d_2/MaxPool}}]] I need any assistance to exceed this issue.
You can change your import to the below mentioned line from keras import backend as K K.set_image_data_format('channels_first ')
to
from keras import backend as K K.set_image_data_format('channels_last ')
In Docker container. CPU-only. Docker image: tensorflow/tensorflow:latest (65e150502892) Updated TensorFlow with
pip install -U tf-nightly
to fix issue #80 . In container cloned the benchmarks. Start benchmarks with# python tf_cnn_benchmarks.py --batch_size=32 --model=resnet50
Output: