Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Cannot convert '32' to a shape. #15

Open
rezapoorzare1 opened this issue Jan 21, 2025 · 10 comments
Open

ValueError: Cannot convert '32' to a shape. #15

rezapoorzare1 opened this issue Jan 21, 2025 · 10 comments

Comments

@rezapoorzare1
Copy link

Hello there,

What can be the cause for the following error?
ValueError: Cannot convert '32' to a shape.

Thanks

@MiquelFerriol
Copy link
Collaborator

Hello,

This error is likely caused by TensorFlow itself, and it seems you might be using an incompatible TensorFlow version. Could you please confirm whether you are using TensorFlow 2.6?

If that is indeed the case, could you also provide the steps you followed so that we can reproduce the error on our end?

Thank you!
Miquel

@rezapoorzare1
Copy link
Author

Thanks for the answer.

The version of the Python is: Python 3.10.12

The version of the TensorFlow is: Version: 2.18.0

These can be the root for the issue?

@MiquelFerriol
Copy link
Collaborator

Yes, the issue is likely due to version incompatibilities, as TensorFlow 2.18.0 and Python 3.10.12 are incompatible with the repository.

I recommend using TensorFlow 2.6, which you can install via pip install -r requirements.txt, and downgrading Python to version 3.7 or 3.8, as TensorFlow 2.6 does not support Python 3.10.

Let me know if you encounter any issues!

@rezapoorzare1
Copy link
Author

Thanks a lot.
Let me try them and come back to you.

@rezapoorzare1
Copy link
Author

It seems that the specific version TensorFlow 2.6 is no longer available on the official Python Package:
ERROR: Could not find a version that satisfies the requirement tensorflow==2.6 (from versions: 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.11.1, 2.12.0rc0, 2.12.0rc1, 2.12.0, 2.12.1, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0, 2.15.0.post1, 2.15.1, 2.16.0rc0, 2.16.1, 2.16.2, 2.17.0rc0, 2.17.0rc1, 2.17.0, 2.17.1, 2.18.0rc0, 2.18.0rc1, 2.18.0rc2, 2.18.0)
ERROR: No matching distribution found for tensorflow==2.6

@rezapoorzare1
Copy link
Author

I have downgraded Python to 3.7, but it is not possible to install TensorFlow 2.6, and still the error is there.

@MiquelFerriol
Copy link
Collaborator

Are you still encountering the same error even after downgrading the Python version? That’s unusual. According to the official TensorFlow installation guide, Python 3.7 should be compatible, and I’ve personally verified this.
Please ensure that your environment is actually using Python 3.7 and not defaulting to Python 3.10.

Let me know if you need further assistance troubleshooting this.

@rezapoorzare1
Copy link
Author

Thanks a lot for the answer.

I have changed the Ubuntu version and could handle that error; however, I am encountering the following error now:

2025-01-22 14:22:50.731900: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory

2025-01-22 14:22:50.731924: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

Traceback (most recent call last):

File "main.py", line 6, in

from model import GNN_Model

File "../model.py", line 22, in

class GNN_Model(tf.keras.Model):

File "/home/reza/.local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 62, in getattr

module = self._load()

File "/home/reza/.local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 45, in _load

module = importlib.import_module(self.__name__)

File "/usr/lib/python3.7/importlib/init.py", line 127, in import_module

return bootstrap.gcd_import(name[level:], package, level)

File "/home/reza/.local/lib/python3.7/site-packages/keras/init.py", line 21, in

from keras import models

File "/home/reza/.local/lib/python3.7/site-packages/keras/models/init.py", line 18, in

from keras.engine.functional import Functional

File "/home/reza/.local/lib/python3.7/site-packages/keras/engine/functional.py", line 26, in

from keras import backend

File "/home/reza/.local/lib/python3.7/site-packages/keras/backend.py", line 34, in

from keras.engine import keras_tensor

File "/home/reza/.local/lib/python3.7/site-packages/keras/engine/keras_tensor.py", line 19, in

from keras.utils import object_identity

File "/home/reza/.local/lib/python3.7/site-packages/keras/utils/init.py", line 48, in

from keras.utils.layer_utils import get_source_inputs

File "/home/reza/.local/lib/python3.7/site-packages/keras/utils/layer_utils.py", line 26, in

from keras import initializers

File "/home/reza/.local/lib/python3.7/site-packages/keras/initializers/init.py", line 22, in

from keras.initializers import initializers_v2

File "/home/reza/.local/lib/python3.7/site-packages/keras/initializers/initializers_v2.py", line 23, in

from keras.dtensor import utils

File "/home/reza/.local/lib/python3.7/site-packages/keras/dtensor/init.py", line 22, in

from tensorflow.compat.v2.experimental import dtensor as dtensor_api

ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (/home/reza/.local/lib/python3.7/site-packages/tensorflow/_api/v2/compat/v2/experimental/init.py)

@rezapoorzare1
Copy link
Author

I think it is because of the old version of TensorFlow (2.6), right?

@rezapoorzare1
Copy link
Author

I could handle it by downgrading the Keras version! Now the training is working. Now in the prediction file, I encounter:

ModuleNotFoundError: No module named 'read_dataset'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants