module 'tensorflow' has no attribute 'contrib' while - python

About OC: Ubuntu 16.04 LTS x86_64; GRX CUDA 10.2; cudnn ... etc.
TF: 2.1.0; Python 3.6
About the problem:
When I launch module_main.py an error is displayed. When I launch it /legacy/train.py similarly, an error appears.
Is it possible to fix this problem without downgrading the tensorflow version and without reinstalling the drivers?
Is changing the code via a script the only way?
Logs below:
model_main.py
Traceback (most resent call last):
File "models/research/object_detection/model_main.py",
line 26, in <module> from object_detection import model_lib
File "/root/ObjectDetection/models/research/object_detection/model_lib.py"
line 27, in <module> from object_detection import eval_lib
File "/root/ObjectDetection/models/research/object_detection/eval_util.py",
line 40, in <module> slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'
Also using conda env
thx, for some advice

I faced the same issue. Tensorflow 2.0 has removed tf.contrib. I tried to fixed the error by changing the code. And it lead to many other error.
I fixed this issue by downgrading tensorflow to 1.14.0
Run these commands on terminal:
pip uninstall tensorflow
pip install tensorflow==1.14.0

Related

How to install tensorflow without pip in the right way?

So I have installed tensorflow with pip using pip install tensorflow==1.15 a few days ago, today I wanted to search for my models-master file and I didn't find it. I uninstalled tensorflow using pip uninstall tensorflow and then I installed it from the github and added it to the folder of the project I am working on like, it is in the same folder as the .py files of my original project. This is because I need to use protoc on the files because I got error messages before. I think I got the protoc part down now but I can't test it, because whenever I want to run my main file, I get this error message:
Traceback (most recent call last):
File "C:\Users\user\Desktop\captcha solver\main_.py", line 1, in <module>
from CAPTCHA_object_detection import *
File "C:\Users\user\Desktop\captcha solver\CAPTCHA_object_detection.py", line 18, in <module>
from object_detection.utils import ops as utils_ops
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection\utils\ops.py", line 291, in <module>
dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'
I think this is because of the way I installed tensorflow, but I don't know what I did wrong, I have never installed modules without pip though.

realtime object detection No module named 'tensorflow.compat.v1'

I am following a Real time object detection on https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top and I have hit a road block I followed all the instructions and checked for any errors but still got this error
(I am using windows)
Traceback (most recent call last): File "object_detection_test.py",
line 15, in <module>
from utils import label_map_util File "C:\Users\1rock\Documents\TensorFlow\models\research\object_detection\utils\label_map_util.py",
line 27, in <module>
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
I used pip install --ignore-installed --upgrade tensorflow==1.9 just what the link above said and whilst running I got these packages and their versions and an error hope it would be relevant to the question
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipywidgets 7.6.0 requires jupyterlab-widgets>=1.0.0, which is not installed.
Successfully installed absl-py-0.11.0 astor-0.8.1 gast-0.4.0 grpcio-1.34.0 importlib-metadata-3.3.0 markdown-3.3.3 numpy-1.19.4 protobuf-3.14.0 setuptools-51.0.0.post20201207 six-1.15.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 wheel-0.36.2 zipp-3.4.0
I used pip install --ignore-installed --upgrade tensorflow==1.9
line 27, in
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
TF 1.9 and earlier do not have compat module. To use it you need TF 1.10+. Its better to use conda install everywhere possible with conda virtual enviroment.
Also since you are using tensorflow models make sure you has corresponding version of repository, for example latest TF1.x version located here

AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator' , when trying to use TensorBoard

I made some log files using tensorboard but I can't access them.
Using
tensorboard or tensorboard --logdir=logs/ on the command prompt
gives the following error:-
C:\Users\User>tensorboard
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\Scripts\tensorboard-script.py", line 6, in <module>
from tensorboard.main import run_main
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\main.py", line 40, in <module>
from tensorboard import default
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\default.py", line 38, in <module>
from tensorboard.plugins.beholder import beholder_plugin
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\__init__.py", line 15, in <module>
from tensorboard.plugins.beholder.beholder import Beholder
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\beholder.py", line 25, in <module>
from tensorboard.plugins.beholder import im_util
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\im_util.py", line 89, in <module>
class PNGDecoder(util.PersistentOpEvaluator):
AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator'
I tried this solution, but it did not help.
I also had a big fight with this problem. What eventually worked for me was the following:
pip uninstall tensorflow
pip uninstall tensorboard
conda show OR pip show --> have a look at which other tensorflow related packages you have installed and remove them.
Go to site-packages and remove tensorflow/tensorboard folders (look for any folder in your filesystem related to a tensorflow / tensorboard installation)
conda clean --all (not sure if this is necessary, but it was one of
my steps and might be relevant)
Reinstall tensorflow and tensorboard. Preferably use conda as it is faster by several orders of magnitude
One of my main sources in solving this issue was this github issue thread:
https://github.com/tensorflow/tensorboard/issues/1724
Try to install these packages with Conda Run:
conda install -c anaconda tensorflow-gpu
conda install -c anaconda keras

Tensorflow error : DLL load failed: The specified procedure could not be found

I tried to install tensorflow cpu using pip in my windows8.1 64bit python3.6.0
using pip install tensorflow
but it gives me this error:
Traceback (most recent call last): File "C:\Users\Laitooo
San\Desktop\tf.py", line 1, in <module>
import tensorflow as tf File "C:\Users\Laitooo San\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py",
line 24, in <module>
from tensorflow.python import * File "C:\Users\Laitooo San\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py",
line 52, in <module>
from tensorflow.core.framework.graph_pb2 import * File "C:\Users\Laitooo
San\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py",
line 6, in <module>
from google.protobuf import descriptor as _descriptor File "C:\Users\Laitooo
San\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py",
line 47, in <module>
from google.protobuf.pyext import _message ImportError: DLL load failed: The specified procedure could not be found.
I downloaded python36.dll and made sure all other .dll is there and install Microsoft visual c++ 2015
I also uninstalled tensorflow and installed another version several times but without any result.
I had this error as well, and was able to resolve it by downgrading protobuf from 3.6.1 to 3.6.0:
pip install protobuf==3.6.0
windows 10
python 3.6
Cuda 9.0
cudnn-9.0-windows10-x64-v7.6.3.30
tensorflow-gpu == 1.12.0
keras == 2.2.4
problem was:
ImportError: DLL load failed: The specified procedure could not be
found.
solved with:
pip install protobuf==3.6.0
There is a similar issue on Github:
Tensorflow issue
Problem should be resolved if you install the wheel file provided in one of the answers. You can find the wheel file here.
Wheel file
You can install the wheel file with pip. First change the current directory to install location. Then,
pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl
All official tensorflow binaries since 1.6 were made with AVX, rendering older CPUs unsupported.
In order to install recent tensorflow versions on an older CPU you can simply install tensorflow from a non-avx built wheel ( you can find some here)
pip install <path to the downloaded .whl file>
its the problem with python=3.6.0
Upgrade to any higher versions of python 3.6
Updating from python 3.6.0 to python 3.6.4 fixed this issue for me.
I got this (unhelpful) error after installing on python 3.7. Turns out I had not installed cuDNN, the neural network package. After that, it runs without issue.
I had the same problem.
I made it work by uninstalling scipy and then reinstalling.
First uninstall seaborn.
pip uninstall seaborn
then uninstall scipy.
pip uninstall scipy.
After that install both scipy and seaborn.
pip install scipy,
pip install seaborn
I hope it helps

importerror no module named tensorflow windows

import tensorflow as tf Traceback (most recent call last):
File "<ipython-input-5-41389fad42b5>", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I am getting the following error after installation of tensorflow in anaconda using windows. I have followed the tensorflow installation steps
At first it was running properly but when i tried to uninstall and reinstall tensorflow, this error pops up. I tried uninstalling Anaconda itself and reinstalling but was of no help. Tensorflow is getting installed but when i try the import step it shows the above error.
Solved: Python 3.6 is incompatible with tensorflow and had to create tensorflow environment for python 3.5.
conda create -n tensorflow python=3.5 anaconda
Activated it in command prompt and launched spyder from it which changed my python version to 3.5. Now was able to import tensorflow properly.
If you installed tensorflow using Anaconda inside an Anaconda environment, you will need to activate this environment. Only then can you import tensorflow.

Categories