No module named 'tensorflow.contrib'

Have spent a couple days troubleshooting. This is the complete installation guide for a course I am taking

When I try and enter the following in cmd

$python run_webcam.py --camera video.mp4

I get the following error

ModuleNotFoundError: No module named 'tensorflow.contrib'

The offending line is

import tensorflow.contrib.tensorrt as trt

Here are my setup specs

  • Windows 10

    Python 3.6.8

    CUDA 10.0

    cuDNN v 7.6.2

    Tensorflow (gpu) 1.14.0

    GeForce GTX 960M

    Driver version 431.60

    Intel Core i7-6700HQ 2.6 GHz*

Any feedback or troubleshooting steps appreciated!

Is it possible tensorflow is in correctly installed? When I do a $pip list I get

tensorflow 1.14.0
tensorflow-estimator 1.14.0
tensorflow-gpu 2.0.0b1

I get almost identical error if instead of cmd I run using Anaconda prompt with Python 3.7.3 “No module named 'tensorflow.python.compiler.”

Also confirmed that import tensorflow DOES work in a Python shell.

So bottom line is that the tensorRT module is missing. Then how to install? A quick google shows no Windows installer or support? I already tried uninstalling then reinstalling tensorflow and tensorflow-gpu

Finally works but getting 1 frame every 2-4 seconds with canned 1080p video!

here are my specs

hardware + driver

GeForce GTX 960M
Driver version 431.60
Intel Core i7 6700HQ CPU 2.6 GHz
15.87 GB RAM

Software
Windows 10
CUDA 10.0
Python 3.6.8
tensorflow 1.14.0

Questions

  1. I had to comment out the line

import tensorflow.contrib.tensoort as trt

to avoid compile errors.

Could this be causing my performance issues?

  1. I have both tensorflow and tensorflow-gpu installed. How do I know which one I am running?

  2. What other steps should I take to help troubleshoot performance?

Hello batch44

I had same issue and my working environment seems to me same like yours(os, python, package version…etc)

Did you get any answer yet? if you did, let us know, thank you!

Hey I have the same problem I followed this tutorial

how did you solve it?

Thanks

thanks for the solution… @consistant1y, just remove that line “import tensorflow.contrib.tensoort as trt” from estimator.py file

To address this issue, you have a few options:

  • Update Your Code: If you’re using TensorFlow 2.x, update your code to use the latest TensorFlow APIs. Many functionalities from tensorflow.contrib have been integrated into the core TensorFlow library or are available as separate packages.
  • Use TensorFlow 1.x: If you need to run legacy code that relies on tensorflow.contrib, you can install an older version of TensorFlow (1.15 is the last version that included contrib). You can do this with pip:

bashCopy code

pip install tensorflow==1.15

However, be aware that TensorFlow 1.x is no longer actively maintained.

  • Check for Alternative Libraries: For some specific modules in tensorflow.contrib, alternative standalone libraries are available. For example, tf.contrib.slim has some parallels with tf_slim, and tf.contrib.rnn functionalities are mostly available in core TensorFlow.