microsoft / tensorflow-directml

Fork of TensorFlow accelerated by DirectML
Apache License 2.0
454 stars 32 forks source link

AttributeError: module 'tensorflow' has no attribute 'float32' #408

Open Coloradohusky opened 1 year ago

Coloradohusky commented 1 year ago

System Information

Python Environment

Python Version : 3.7.9 TensorFlow-DirectML : 1.15.8

DirectX Device

Description : Radeon RX 580 Series Manufacturer : Advanced Micro Devices, Inc. Chip Type : AMD Radeon Graphics Processor (0x67DF) Dedicated Memory : 8170 MB Driver Version : 30.0.21020.2 Driver Model : WDDM 2.7 Driver Date : 5/23/2022 5:00:00 PM Feature Levels : 12_0,11_1,11_0,10_1,10_0,9_3,9_2,9_1


# Repro Details

**Describe the current behavior**
Installing `tensorflow-directml` on a fresh `venv`, and running `import tensorflow.compat.v1 as tf` each time, as per https://learn.microsoft.com/en-us/windows/ai/directml/gpu-tensorflow-windows.
First issue was `ModuleNotFoundError: No module named 'matplotlib'`, fixed with `pip install matplotlib`.
Second issue was `ModuleNotFoundError: No module named 'IPython'`, fixed with `pip install ipython`.
Third issue was `ModuleNotFoundError: No module named 'object_detection'`, so I ran `pip install tensorflow-object-detection-api`. This caused:

tensorflow-directml 1.15.8 requires numpy<1.19.0,>=1.16.0, but you have numpy 1.21.6 which is incompatible. tensorflow-directml 1.15.8 requires tensorboard<1.16.0,>=1.15.0, but you have tensorboard 2.11.2 which is incompatible. tensorflow-directml 1.15.8 requires tensorflow-estimator==1.15.1, but you have tensorflow-estimator 2.11.0 which is incompatible.

Final issue I ran into was `AttributeError: module 'tensorflow' has no attribute 'float32'`, which I am unsure how to fix. I ran `pip install tensorflow-directml` again to see if that fixed anything, but it had no effect. I also tried `pip install --upgrade --force-reinstall tensorflow` and `pip install --upgrade --force-reinstall tensorflow-directml`, but they also had no effect.
**Describe the expected behavior**
`import tensorflow.compat.v1 as tf` runs with no errors.
**Other info / logs**

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import tensorflow.compat.v1 as tf Traceback (most recent call last): File "", line 1, in File "C:\Users\Riley\Desktop\Misc stuff\tensorflow\tensorflow.py", line 15, in from object_detection.utils import ops as utils_ops File "C:\Users\Riley\Desktop\Misc stuff\tensorflow\venv\lib\site-packages\object_detection\utils\ops.py", line 291, in dtype=tf.float32): AttributeError: module 'tensorflow' has no attribute 'float32'

Petros626 commented 1 year ago

In my uninstalling tensorflow directml deactivating my venv, restart and then installing tensorflow directml in the venv, helped