TensorFlow GPU problem 'libnvinfer.so.7' and ' 'libnvinfer.so.7'' could not load

Question:

I installed TensorFlow under WSL 2, Ubuntu 22.04 (Jammy Jellyfish), I followed the instructions in Install TensorFlow with pip.

*I also installed Nvidia drivers for Windows and in my other WSL 2, I use GPU-supported simulation program.

Everything seemed OK. I didn’t get any error message during installation, but when I imported TensorFlow in Python 3, I got this error:

2023-02-12 14:49:58.544771: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
2023-02-12 14:49:58.544845: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2023-02-12 14:49:58.544874: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: 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.

I searched my libnvinfer_plugin.so.7 files:

sudo find / -name libnvinfer.so.7  2> /dev/null

and I found them in this directory:

cat /usr/lib/x86_64-linux-gnu/libnvinfer.so.7

and I added this directory to LD_LIBRARY_PATH like in Could not load dynamic library 'libnvinfer.so.7', but nothing changed. Still TensorFlow is working, but I can’t use the GPU.

nvidia-smi:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01    Driver Version: 516.94       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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 ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P0    22W /  N/A |      0MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

nvcc–version:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0

*The TensorFlow version is: 2.11.0

So, how can I fix this problem?

Asked By: BARIS KURT

||

Answers:

I changed version and the problem was solved:

pip install --upgrade tensorflow==2.8

Note: When I use v2.10, I get the same error message. v2.8 is stable now.

Answered By: BARIS KURT
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.