Leevo
Leevo

Reputation: 1753

TensorFlow 2.1 returns Warnings when loaded from terminal and Error when loaded from Jupyter

I have installed tensorflow 2.1.0 in a virtualenv on my home laptop (Ubuntu 18.04). When I import tensorflow as tf from terminal I get the following warning:

2020-03-12 12:17:56.485098: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory

2020-03-12 12:17:56.485179: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory

2020-03-12 12:17:56.485189: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

However, the import works and I can run code as usual.

But when I try to do the same in a Jupyter Notebook, I get error. import tensorflow as tf returns:

ModuleNotFoundError: No module named 'tensorflow'

I have no GPU on my laptop, but tensorflow 2.1 should be able to run on either GPU and CPU-only machines. And in fact I installed it successfully at work with no problems. What can I do to fix this?

Upvotes: 1

Views: 696

Answers (1)

user11530462
user11530462

Reputation:

You can suppress the Warnings message by using below code

import logging, os
logging.disable(logging.WARNING)
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
import tensorflow as tf

Regarding error on Jupyter notebook,

Open anaconda-navigator and create new environment and launch the jupyter-notebook. Now install tensorflow

!pip install tensorflow

Upvotes: 1

Related Questions