Skip to content

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

@Coloradohusky

Description

@Coloradohusky

System Information

  • Windows 10 Version 22H2 (OS Build 19045.2965
  • Python Version 3.7.9
  • TensorFlow-DirectML Version 1.15.8
  • AMD Radeon RX580 Version 22.10.20-220524a-380149C-AMD-Software-PRO-Edition
Host System
--------------------------------------------------------------------------------
Windows 10 Version  : Windows 10 Education 64-bit (10.0, Build 19045) (19041.vb_release.191206-1406)
Processor           : AMD Ryzen 5 2600 Six-Core Processor             (12 CPUs), ~3.4GHz
Memory              : 49152MB RAM
DirectX Version     : DirectX 12

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 "<stdin>", line 1, in <module>
  File "C:\Users\Riley\Desktop\Misc stuff\tensorflow\tensorflow.py", line 15, in <module>
    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 <module>
    dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions