Giter VIP home page Giter VIP logo

Comments (8)

reedwm avatar reedwm commented on May 18, 2024 6

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.

from benchmarks.

Al-Badri179 avatar Al-Badri179 commented on May 18, 2024 3

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.

from benchmarks.

tfboyd avatar tfboyd commented on May 18, 2024 2

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

from benchmarks.

pyotr777 avatar pyotr777 commented on May 18, 2024

@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.

from benchmarks.

tfboyd avatar tfboyd commented on May 18, 2024

@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).

from benchmarks.

sruthisentil avatar sruthisentil commented on May 18, 2024

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?

from benchmarks.

ShaneYS avatar ShaneYS commented on May 18, 2024

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++?

from benchmarks.

kenil22 avatar kenil22 commented on May 18, 2024

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 ')

from benchmarks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.