Tensorflow question (MaxPool3d, MaxPool3D, MaxPooling3D)!)

Hi all,
I am trying to run an image against an existing model created with Python 3.7 / Tensorflow 2.7
(https://github.com/pboutinaud/SHIVA_PVS). There seems to be some confusion between MaxPool3d (in torch), MaxPool3D (in keras) and possibly MaxPooling3d.

I get this error and can not seem to solve it.

tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op ‘MaxPool3D’ used by {{node model/Enc_Max_D7/MaxPool3D}} with these attrs: [ksize=[1, 2, 2, 2, 1], padding=“VALID”, T=DT_HALF, data_format=“NDHWC”, strides=[1, 2, 2, 2, 1]]
Registered devices: [CPU]
Registered kernels:
device=‘XLA_CPU_JIT’; T in [DT_FLOAT, DT_BFLOAT16, DT_HALF]
device=‘CPU’; T in [DT_FLOAT]

If anybody has any ideas on how to troubleshoot this I would be very grateful!

Roger

On the CPU, you can try using data type float32. Thank you.

Hi Roger, welcome to the forum!

I didn’t understand some details,

Are you converting the model from PT to TF? or is the model already converted?
or did you train the model from scratch?

Hi all,
Thank you for your replies!
According to the developer, “the MaxPool3D layer is not correctly implemented for the CPU version of tensorflow 2.7, I couldn’t find an easy way to fix that and I am currently waiting for tensorflow to fix that problem in a future version.”
Alas!
R

Can you try with the latest version TF2.10 and let us know if the issue still continues? Thank you!

@chunduriv I had the same issue. Upgraded to tf 2.10 but the issue persist.

@Camilo_Andres_Pestan,

Welcome to the Tensorflow Forum!

Could you please share simple standalone code and error stack trace to debug the issue?

Thank you!

Hi Experts,

I’m a researcher in the filed of neuroscience using MRI techniques.
I’m new to pyhton and tensorflow.

I have the same question raised by Dr. Roger ( @rogiedodgie).
I’m trying to analyze MRI data with use of the following a python-based code (GitHub - pboutinaud/SHIVA_PVS: Perivascular (PVS) or Virchow–Robin Spaces (VRS) segmentation with a 3D Unet). This code computes with use of the 3D U-Shaped Neural Network that was already trained with the pre-exsiting data in machine-learning procedure (https://www.frontiersin.org/articles/10.3389/fninf.2021.641600/full). This code demands the tensorflow for computaion.

I’m using python3.10 on mac terminal and installed the tensorflow 2.15.0.
Mac OS is ventura 13.6.1.
I reached this website and read the suggestions from the Team members, but I did not understand.
Could you tell me the solution if you have already fixed ? Or I would greatly appreciate if you could give me suggestions with consiring me as a biginner. I want to achive successful analysis with use of this code.

The code history as follows:

input the folliwing:
python3 /Users/username/Downloads/SHIVA_PVS/predict_one_file.py -i /Users/username/mri/young_healthy/MRI_resliced.nii -m /Users/username/Downloads/SHIVA_PVS/PVS/v1/T1.PVS/20211030-162753_Unet3Dv2-10.7.2-1.8-T1.VRS_fold_1x6_pi_fold_0_model.h5 -b /Users/username/mri/young_healthy/brain_reslice.nii -o /Users/username/mri/young_healthy/pv_MRI_resliced --verbose --gpu 0

terminal returns:
2023-11-16 07:55:41.891278: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Trying to run inference on GPU 0
WARNING:tensorflow:Mixed precision compatibility check (mixed_float16): WARNING
The dtype policy mixed_float16 may run slowly because this machine does not have a GPU. Only Nvidia GPUs with compute capability of at least 7.0 run quickly with mixed_float16.
If you will use compatible GPU(s) not attached to this host, e.g. by running a multi-worker model, you can ignore this warning. This message will only be logged once
INFO : Predicting fold : 20211030-162753_Unet3Dv2-10.7.2-1.8-T1.VRS_fold_1x6_pi_fold_0_model
Traceback (most recent call last):
File “/Users/username/Downloads/SHIVA_PVS/predict_one_file.py”, line 125, in
prediction = model.predict(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py”, line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/eager/execute.py”, line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op ‘MaxPool3D’ used by {{node model/Enc_Max_D7/MaxPool3D}} with these attrs: [T=DT_HALF, data_format=“NDHWC”, ksize=[1, 2, 2, 2, 1], strides=[1, 2, 2, 2, 1], padding=“VALID”]
Registered devices: [CPU]
Registered kernels:
device=‘XLA_CPU_JIT’; T in [DT_FLOAT, DT_BFLOAT16, DT_HALF]
device=‘CPU’; T in [DT_FLOAT]
device=‘CPU’; T in [DT_BFLOAT16]