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

AttributeError: module 'tensorflow' has no attribute 'compat' #40422

Closed
JuliaH22 opened this issue Jun 12, 2020 · 17 comments
Closed

AttributeError: module 'tensorflow' has no attribute 'compat' #40422

JuliaH22 opened this issue Jun 12, 2020 · 17 comments
Assignees
Labels
TF 2.1 for tracking issues in 2.1 release type:build/install Build and install issues

Comments

@JuliaH22
Copy link


AttributeError Traceback (most recent call last)
in
1 get_ipython().run_line_magic('matplotlib', 'inline')
2 import matplotlib.pyplot as plt
----> 3 import tensorflow as tf
4 import numpy as np
5 import pandas as pd

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_init_.py in
99
100 # We still need all the names that are toplevel on tensorflow_core
--> 101 from tensorflow_core import *
102
103 # These should not be visible in the main tf module.

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_init_.py in
44 from . _api.v2 import autograph
45 from . _api.v2 import bitwise
---> 46 from . _api.v2 import compat
47 from . _api.v2 import config
48 from . _api.v2 import data

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat_init_.py in
37 import sys as _sys
38
---> 39 from . import v1
40 from . import v2
41 from tensorflow.python.compat.compat import forward_compatibility_horizon

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py in
30 from . import autograph
31 from . import bitwise
---> 32 from . import compat
33 from . import config
34 from . import data

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py in
37 import sys as _sys
38
---> 39 from . import v1
40 from . import v2
41 from tensorflow.python.compat.compat import forward_compatibility_horizon

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py in
27
28 from . import compat
---> 29 from tensorflow._api.v2.compat.v1 import app
30 from tensorflow._api.v2.compat.v1 import audio
31 from tensorflow._api.v2.compat.v1 import autograph

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat_init_.py in
37 import sys as _sys
38
---> 39 from . import v1
40 from . import v2
41 from tensorflow.python.compat.compat import forward_compatibility_horizon

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py in
30 from . import autograph
31 from . import bitwise
---> 32 from . import compat
33 from . import config
34 from . import data

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py in
37 import sys as _sys
38
---> 39 from . import v1
40 from . import v2
41 from tensorflow.python.compat.compat import forward_compatibility_horizon

~\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py in
665 _current_module = _sys.modules[name]
666 try:
--> 667 from tensorflow_estimator.python.estimator.api._v1 import estimator
668 _current_module.path = (
669 [_module_util.get_parent_dir(estimator)] + _current_module.path)

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator_init_.py in
8 import sys as _sys
9
---> 10 from tensorflow_estimator._api.v1 import estimator
11
12 del _print_function

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator_api\v1\estimator_init_.py in
8 import sys as _sys
9
---> 10 from tensorflow_estimator._api.v1.estimator import experimental
11 from tensorflow_estimator._api.v1.estimator import export
12 from tensorflow_estimator._api.v1.estimator import inputs

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator_api\v1\estimator\experimental_init_.py in
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
11 from tensorflow_estimator.python.estimator.canned.kmeans import KMeansClustering as KMeans
12 from tensorflow_estimator.python.estimator.canned.linear import LinearSDCA

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py in
31 from tensorflow.python.keras.utils import losses_utils
32 from tensorflow.python.util.tf_export import estimator_export
---> 33 from tensorflow_estimator.python.estimator import estimator
34 from tensorflow_estimator.python.estimator.canned import head as head_lib
35 from tensorflow_estimator.python.estimator.canned import optimizers

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator\python\estimator\estimator.py in
51 from tensorflow_estimator.python.estimator import model_fn as model_fn_lib
52 from tensorflow_estimator.python.estimator import run_config
---> 53 from tensorflow_estimator.python.estimator import util as estimator_util
54 from tensorflow_estimator.python.estimator.export import export_lib
55 from tensorflow_estimator.python.estimator.mode_keys import ModeKeys

~\AppData\Roaming\Python\Python37\site-packages\tensorflow_estimator\python\estimator\util.py in
73
74
---> 75 class _DatasetInitializerHook(tf.compat.v1.train.SessionRunHook):
76 """Creates a SessionRunHook that initializes the passed iterator."""
77

AttributeError: module 'tensorflow' has no attribute 'compat'

@JuliaH22
Copy link
Author

Hi everyone
after a long attempt to install tensorflow gpu version by following this tutorial:
https://www.youtube.com/watch?v=qrkEYf-YDyI&t=295s
I always find myself facing the above error. Can someone please help me?

@ymodak
Copy link
Contributor

ymodak commented Jun 13, 2020

What is the TF version you are trying to install? Also what steps did you follow?

@ymodak ymodak added type:build/install Build and install issues stat:awaiting response Status - Awaiting response from author and removed type:bug Bug labels Jun 13, 2020
@AnimeshMaheshwari22
Copy link

AnimeshMaheshwari22 commented Jun 13, 2020

You can try uninstalling and re-installing TensorFlow. Also, check this link https://www.tensorflow.org/guide/migrate

@JuliaH22
Copy link
Author

What is the TF version you are trying to install? Also what steps did you follow?

At first I uninstalled anaconda and all the NVIDIA programs I had before, to start over from scratch.
Then I followed every step of this tutorial in detail:
https://www.youtube.com/watch?v=qrkEYf-YDyI
Step 1: I have NVIDIA Geforce GTX 1050 Ti, I installed the GTX 1650 driver
Step 2: I downloaded the updated Setup Script provided in https://github.com/jeffheaton/t81_558_deep_learning
To search for compatible version of Tensorflow 2.1.0: https://www.tensorflow.org/install/gpu?hl=fr
Step 3: I installed CUDA Toolkit 10.1
Step 4: I installed cuDNN 7.6.5 for Cuda 10.1
I've added all the necessary paths in my path environment
Step 5: I installed TensorRT 6.0
Step 6: Once I installed miniconda, i did the following setup commands using my command prompt:
-conda
-conda install jupyter
-Once jupyter installation is done, I run the installaton script downloaded in step 2 using this command dir *.yml.
Then, i run this command: conda env create -v -f tensorflow-gpu.yml, It took me a long time.
Later I used "conda env create -f tensorflow-gpu.yml". Again, several things have been installed.
Just after i run: python -m ipykernel install --user --name tensorflow --display-name "Python 3.7 (tensorflow)" . Then python
Once tensorflow activated using "conda activate tensorflow", I get the error on top when I try to import Tensorflow as tf

@JuliaH22
Copy link
Author

You can try uninstalling and re-installing TensorFlow. Also, check this link https://www.tensorflow.org/guide/migrate

I'm still getting the same error, even with the reinstallation of tensorflow using pip.

@AnimeshMaheshwari22
Copy link

You can follow the steps mentioned in the article below and check if it works.
https://towardsdatascience.com/tensorflow-gpu-installation-made-easy-use-conda-instead-of-pip-52e5249374bc

If it does not work, try pip install tensorflow==2.1. Found this here: #37525.

You can try uninstalling and re-installing TensorFlow. Also, check this link https://www.tensorflow.org/guide/migrate

I'm still getting the same error, even with the reinstallation of tensorflow using pip.

@JuliaH22
Copy link
Author

You can follow the steps mentioned in the article below and check if it works.
https://towardsdatascience.com/tensorflow-gpu-installation-made-easy-use-conda-instead-of-pip-52e5249374bc

If it does not work, try pip install tensorflow==2.1. Found this here: #37525.

You can try uninstalling and re-installing TensorFlow. Also, check this link https://www.tensorflow.org/guide/migrate

I'm still getting the same error, even with the reinstallation of tensorflow using pip.

Same problem even with pip install tensorflow==2.1 ! Sorry, i already saw that issue

@JuliaH22
Copy link
Author

the steps mentioned in the article

Thank you for this article. I will follow these steps

@amahendrakar amahendrakar added stat:awaiting response Status - Awaiting response from author and removed stat:awaiting response Status - Awaiting response from author labels Jun 15, 2020
@mihaimaruseac
Copy link
Collaborator

Please properly fill in issue template and use the proper Markdown formatting around errors and code blocks.

@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler google-ml-butler bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Jun 22, 2020
@ltorres321
Copy link

I have the same exact issue Here is my post I cant find a working solution for this issue
https://stackoverflow.com/questions/62622704/attributeerror-module-tensorflow-has-no-attribute-compat-when-loading-tf-co
In google I see post to install MV C++ i already have VS 2019 installed

@mindUpGit
Copy link

Same issue for us.
We have installed the same combo on another machine ,,, it works.
Here we have a notebook with internal graphics card and one additional GTX 1650
GTX driver: 442.70
CUDA 10.1
cuDNN 7.6.5.32
TensorRT 6.0
system path changed like specified
We are using anaconda for test purpose.
packages installed all via conda install - no pip.

@mindUpGit
Copy link

ISSUE FIXED for me

Indeed the command "conda install tensorflow-gpu==2.1.0" installed version 2.2.0 of tensorflow-estimator.
After "conda install tensorflow-estimator==2.1.0" everything works fine

@amahendrakar
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@amahendrakar amahendrakar added TF 2.1 for tracking issues in 2.1 release and removed stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author labels Jul 2, 2020
@mikechen66
Copy link

After "conda install tensorflow-estimator==2.1.0", everything works fine for me too .

@14243444

This comment has been minimized.

@tensorflow tensorflow locked as resolved and limited conversation to collaborators Jul 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
TF 2.1 for tracking issues in 2.1 release type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

9 participants