Why tensorflow not working after installing tensorflow-gpu in Ubuntu 19.10?

Viewed 780

I had a python code which uses tensorflow for machine learning

The important thing to note is that the code was working fine with tensorflow before installing tensorflow-gpu.

After installing tensorflow-gpu and then running the file gave the following error

  File "fileName.py", line 1, in <module>
    import tensorflow as tf
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 84, in <module>
    from tensorflow.python import keras
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/__init__.py", line 27, in <module>
    from tensorflow.python.keras import models
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/models.py", line 24, in <module>
    from tensorflow.python.keras import metrics as metrics_module
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/metrics.py", line 37, in <module>
    from tensorflow.python.keras.engine import base_layer
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 51, in <module>
    from tensorflow.python.keras import initializers
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/initializers/__init__.py", line 127, in <module>
    populate_deserializable_objects()
  File "/home/<xyz>/.local/lib/python3.7/site-packages/tensorflow/python/keras/initializers/__init__.py", line 85, in populate_deserializable_objects
    generic_utils.populate_dict_with_module_objects(
AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'

Both the tensorflow and tensorflow-gpu was installed successfully using pip

Installation of tensorflow checked using pip show tensorflow

Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/<xyz>/.local/lib/python3.7/site-packages
Requires: scipy, astunparse, termcolor, tensorboard, grpcio, opt-einsum, tensorflow-estimator, google-pasta, h5py, absl-py, protobuf, six, wheel, gast, wrapt, keras-preprocessing, numpy
Required-by:

Installation of tensorflow-gpu checked using pip show tensorflow-gpu

Name: tensorflow-gpu
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/<xyz>/.local/lib/python3.7/site-packages
Requires: google-pasta, tensorflow-estimator, wrapt, absl-py, termcolor, opt-einsum, keras-preprocessing, six, scipy, h5py, protobuf, wheel, numpy, tensorboard, gast, grpcio, astunparse
Required-by:

I have not installed CUDA driver yet. Can this be the problem?

1 Answers

This GitHub issue deals with this. It seems like a conflict with tf-nightly.

Try:

pip uninstall tf-nightly
pip install tensorflow --upgrade --force-reinstall # Or, tensorflow-gpu
Related