onnx-tensorflow
onnx-tensorflow copied to clipboard
NHWC tensor format Tensorflow
The Conv2D op currently only supports the NHWC tensor format on the CPU. The op was given the format: NCHW
How to make a convert?
I also confused in this question, do you have solved ?
No
Because you are running on CPU. Have 3 way for you: 1.Install tensorflow build with mkl, it support ncwh, 2. modify your code to change input datatype from ncwh to nhwc, 3. Run your model on GPU
- Not suitable
- Yes, this is correct, but I did not find a guide on how to do it
- It does not work
1.Easy way:https://pypi.org/project/intel-tensorflow/ 2. That is your problem with your code. Try to find where you feed data and what node you pass data with the wrong format. 3.You mean your problem still meets? or you can't run your model on GPU?
- This installer does not suit me. I have TF serving model
- Yes
I assume the NHWC problem has been fixed by using tensorflow 2.x and the corresponding (most recent) version of onnx and onnx-tf. However in the most recent version other problems occur, at least when trying to convert from pytorch -> onnx -> tf frozen graph -> tflite (which is probably what most people want). See #614 and #617
unfortunately I do not use tf2.X because of bugs.
True, I was recently examining the tensorflow frozen graph (using tf 2.2 ) build from onnx and it still complains about the NHWC problem.
setting os.environ["CUDA_VISIBLE_DEVICES"]="-1"
(as mentioned in this reply https://github.com/onnx/onnx-tensorflow/issues/614#issuecomment-625251872) fixes the issue for me.
diff. versions of library I'm using:
torch==1.6.0
torchvision==0.7.0
onnx==1.7.0
onnxmltools==1.7.0
tensorflow==2.3.0
tensorflow-addons==0.11.0
onnxruntime==1.4.0
git+https://github.com/onnx/onnx-tensorflow.git (currently, it's onnx-tf==1.6.0)
i meet the same poblem, have u fixed it?
@shahirdaya not fixed
@sonfire86 I did not work on this so not sure. Thanks
I remembered that the onnx2keras library had an option to switch the dimensions and rearrange the expected input to NHWC (as opposed to Pytorch's NCHW). Isn't it supported on this library?
1.Easy way:https://pypi.org/project/intel-tensorflow/ 2. That is your problem with your code. Try to find where you feed data and what node you pass data with the wrong format. 3.You mean your problem still meets? or you can't run your model on GPU?
The first way fixes my same problem. Thanks.
The first way fixes my same problem. Thanks.
turned2670 I can't make it work. Would you please explain how exactly did you solve the problem?