TensorFlow 安装:警告:找不到 TensorRT / 无法 dlopen 某些 GPU 库

问题描述 投票:0回答:1

我尝试在 Ubuntu/VSCode 上安装 TensorFlow,但收到这些错误消息,但无法解决问题。

错误信息如下:

(.venv) user:~/Desktop/Code$ python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
2024-05-10 15:36:48.869402: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-05-10 15:36:48.891469: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-05-10 15:36:49.200446: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-05-10 15:36:49.396177: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-10 15:36:49.414822: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2251] 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...

输出:

print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

user:~/Desktop/Code$ /bin/python3 /home/user/Desktop/Code/init.py
2024-05-11 13:30:27.259737: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-05-11 13:30:27.668506: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-05-11 13:30:28.176893: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-05-11 13:30:28.528011: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-11 13:30:28.758580: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2251] 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...
Num GPUs Available:  0

您能指导我如何解决这些问题吗?

谢谢你

我确实安装了 Nvidia 550 驱动程序、CUDA 12.4、CuDnn 和 TensorRt,没有任何问题(CuDnn 测试已通过 - ./mnistCUDNN)

然后我安装了:

pip install tensorflow[and-cuda]

这是我的设置:

(.venv) user:~/Desktop/Code$ neofetch
            .-/+oossssoo+/-.               user
        `:+ssssssssssssssssss+:`           ------------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 22.04.4 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: MS-7D96 2.0 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 6.5.0-28-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 38 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 1992 (dpkg), 9 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.1.16 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080, 1920x1080 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: Unity 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Yaru-dark [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: vscode 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel i7-14700K (28) @ 5.500GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: Intel Device a780 
      -+sssssssssssssssssyyyssss+-         GPU: NVIDIA 01:00.0 NVIDIA Corporation Device 2783 
        `:+ssssssssssssssssss+:`           Memory: 3384MiB / 31854MiB 
            .-/+oossssoo+/-.
                                                                   
                                                                   

(.venv) user:~/Desktop/Code$ nvidia-smi
Fri May 10 15:27:57 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.67                 Driver Version: 550.67         CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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 RTX 4070 ...    Off |   00000000:01:00.0  On |                  N/A |
|  0%   46C    P8              9W /  220W |     390MiB /  12282MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      2232      G   /usr/lib/xorg/Xorg                            173MiB |
|    0   N/A  N/A      2406      G   /usr/bin/gnome-shell                           38MiB |
|    0   N/A  N/A      5068      G   ...,262144 --variations-seed-version=1        104MiB |
|    0   N/A  N/A      5702      G   ...erProcess --variations-seed-version         62MiB |
+-----------------------------------------------------------------------------------------+

以下是一些输出:

(.venv) user:~/Desktop/Code$ python3 --version
Python 3.10.12
(.venv) user:~/Desktop/Code$ python -m pip show tensorflow
Name: tensorflow
Version: 2.16.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /home/user/Desktop/Code/.venv/lib/python3.10/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, ml-dtypes, numpy, opt-einsum, packaging, protobuf, requests, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
Required-by: 
(.venv) user:~/Desktop/Code$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0
tensorflow nvidia tensorrt-python
1个回答
0
投票

here所述,tensorflow 2.16.1 中存在一个错误。您可以降级到 2.15.1 或使用该页面上解释的脚本 env_var.sh。我用这个名称创建了一个脚本,并使用

source ./env_var.sh
来调用它。现在tensorflow可以找到我的GPU了。

© www.soinside.com 2019 - 2024. All rights reserved.