Unable to Get Tensorflow working correctly

Hi,
I’m fairly new to this package.

I’ve been trying to get tensorflow running on my Linux/Ubuntu workstation running an NVidia GTX 1650 Card . I keep getting the message TensorRT not installed (despite installing it) and am not sure what to make of it . I’ve alrady installed python 3 , cuda and tensorflow / tensorrt .


(base) vinayb@sonic:~/Downloads$ pip install tensorrt
Collecting tensorrt
  Using cached tensorrt-8.6.1.tar.gz (16 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: tensorrt
  Building wheel for tensorrt (setup.py) ... done
  Created wheel for tensorrt: filename=tensorrt-8.6.1-py2.py3-none-any.whl size=16971 sha256=cc045b8a85b78797e5e615d71b39192fbd00573d8db2eb2fb8e9a98adaee0853
  Stored in directory: /home/vinayb/.cache/pip/wheels/e0/6b/4e/e2fa4f132c650e4fb0bcb573c67d35cd58ad4889fdebfc0a76
Successfully built tensorrt
Installing collected packages: tensorrt
Successfully installed tensorrt-8.6.1
(base) vinayb@sonic:~/Downloads$ python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
2023-08-18 23:13:26.833319: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2023-08-18 23:13:28.648169: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1960] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]
(base) vinayb@sonic:~/Downloads$ python -V
Python 3.11.4
(base) vinayb@sonic:~/Downloads$ uname 
Linux
(base) vinayb@sonic:~/Downloads$ cat /etc/os-release
NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
....
(base) vinayb@sonic:~/Downloads$ nvidia-smi 
Fri Aug 18 23:18:00 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.86.05              Driver Version: 535.86.05    CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce GTX 1650        Off | 00000000:05:00.0  On |                  N/A |
| 35%   31C    P5              N/A /  75W |    472MiB /  4096MiB |     40%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      3067      G   /usr/lib/xorg/Xorg                          277MiB |
|    0   N/A  N/A      4538      G   /usr/bin/gnome-shell                         89MiB |
|    0   N/A  N/A     29906      G   ...ures=SpareRendererForSitePerProcess        1MiB |
|    0   N/A  N/A     33925      G   ...8568786,17830216290387615158,262144      100MiB |
+---------------------------------------------------------------------------------------+


Fixed . I had to add to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/vinayb/miniconda3/lib/python3.11/site-packages/tensorrt_libs

1 Like

Expanding on the @Vinayb response, for individuals who might be encountering a similar challenge.

There are a few possible reasons why you might be getting the message “TensorRT not installed” even though you have already installed it.

  • You might have installed the wrong version of TensorRT. Make sure that the version of TensorRT that you installed is compatible with the version of CUDA that you are using.
  • You might not have installed TensorRT in the correct location. The default location for installing TensorRT is /usr/local/lib/python3.8/dist-packages/tensorrt.
  • You might not have added the TensorRT library path to your Python environment. You can do this by adding the following line to your .bashrc file:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/dist-packages/tensorrt

Once you have made sure that all of these things are correct, try restarting your computer and then running the Python code that is giving you the error message.

If you are still getting the error message, you can try the following steps:

  • Uninstall TensorRT and then reinstall it.
  • Try installing TensorRT from a different source, such as the NVIDIA website.
  • If you are using a virtual environment, make sure that you have installed TensorRT in the virtual environment.

Hope it helps !

1 Like

Thank you! I have been facing the “TF-TRT Warning: Could not find TensorRT” issue. Your response solved the issue.