failed to run a tensorflow C++ example. # Error Unable to register cuDNN  cuFFT cuBLAS
I finally fixed the privious questions(Now I have modifeid the title and report content) about incompatible version by using protobuf v3.21.9, which should be compitable with tf2.15.

However I got some errors after build my code:
```
2024-03-11 01:24:42.588892: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-11 01:24:42.588959: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-11 01:24:42.589806: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
```

I checked my cuda version is 12.2 and cudnn version is 8.9.7.
Any ideas about this issue? @doolachen The errors indicate a conflict between multiple cuDNN, cuFFT, and cuBLAS libraries during your TensorFlow build process. Could you try cleaning your TensorFlow build directory (bazel clean) and rebuilding it to ensure a fresh build with the updated environment.
Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63366">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63366">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

tf 2.15.0

### Custom code

No

### OS platform and distribution

Linux Ubuntu 22.04

### Mobile device

_No response_

### Python version

3.10.12

### Bazel version

6.1.0

### GCC/compiler version

11.4.0

### CUDA/cuDNN version

12.2/8.9.7

### GPU model and memory

GTX 3090/24G

### Current behavior?

I first compiled TensorFlow using Bazel according to the official documentation, these are my operations:
`git clone https://github.com/tensorflow/tensorflow`
`cd tensorflow`
`git checkout r2.15`
`./configure `
and information is:

> 
> You have bazel 6.1.0 installed.
> Please specify the location of python. [Default is /usr/bin/python3]: 
> 
> 
> Found possible Python library paths:
>   /usr/lib/python3/dist-packages
>   /usr/local/lib/python3.10/dist-packages
> Please input the desired Python library path to use.  Default is [/usr/lib/python3/dist-packages]
> 
> Do you wish to build TensorFlow with ROCm support? [y/N]: n
> No ROCm support will be enabled for TensorFlow.
> 
> Do you wish to build TensorFlow with CUDA support? [y/N]: y
> CUDA support will be enabled for TensorFlow.
> 
> Do you wish to build TensorFlow with TensorRT support? [y/N]: n
> No TensorRT support will be enabled for TensorFlow.
> 
> Found CUDA 12.2 in:
>     /usr/local/cuda-12.2/targets/x86_64-linux/lib
>     /usr/local/cuda-12.2/targets/x86_64-linux/include
> Found cuDNN 8 in:
>     /usr/lib/x86_64-linux-gnu
>     /usr/include
> 
> 
> Please specify a list of comma-separated CUDA compute capabilities you want to build with.
> You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Each capability can be specified as "x.y" or "compute_xy" to include both virtual and binary GPU code, or as "sm_xy" to only include the binary code.
> Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 8.6]: 
> 
> 
> Do you want to use clang as CUDA compiler? [Y/n]: n
> nvcc will be used as CUDA compiler.
> 
> Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: 
> 
> 
> Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]: 
> 
> 
> Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
> Not configuring the WORKSPACE for Android builds.
> 
> Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
> 	--config=mkl         	# Build with MKL support.
> 	--config=mkl_aarch64 	# Build with oneDNN and Compute Library for the Arm Architecture (ACL).
> 	--config=monolithic  	# Config for mostly static monolithic build.
> 	--config=numa        	# Build with NUMA support.
> 	--config=dynamic_kernels	# (Experimental) Build kernels into separate shared objects.
> 	--config=v1          	# Build with TensorFlow 1 API instead of TF 2 API.
> Preconfigured Bazel build configs to DISABLE default on features:
> 	--config=nogcp       	# Disable GCP support.
> 	--config=nonccl      	# Disable NVIDIA NCCL support.
> Configuration finished

check my cuda version using `nvcc -V`:
```
wangchen@wc:~/tfc++test$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Jun_13_19:16:58_PDT_2023
Cuda compilation tools, release 12.2, V12.2.91
Build cuda_12.2.r12.2/compiler.32965470_0
```

check my cudnn version using `cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2`:
```
wangchen@wc:~/tfc++test$ cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 8
#define CUDNN_MINOR 9
#define CUDNN_PATCHLEVEL 7
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

/* cannot use constexpr here since this is a C-only file */
```


and I then compile with bazel:
`bazel build --config=cuda tensorflow:tensorflow_cc`
`bazel build tensorflow:install_headers`

There were no issues, I successfully compiled the header files and link libraries I wanted in the `bazel-bin` folder.
But when I try to compile a C++ sample:
```
#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"

using namespace tensorflow;
using namespace tensorflow::ops;

int main() {
  Scope root = Scope::NewRootScope();
  // Matrix A = [3 2; -1 0]
  auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f} });
  // Vector b = [3 5]
  auto b = Const(root, { {3.f, 5.f} });
  // v = Ab^T
  auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));
  std::vector<Tensor> outputs;
  ClientSession session(root);
  // Run and fetch v
  TF_CHECK_OK(session.Run({v}, &outputs));
  // Expect outputs[0] == [19; -3]
  LOG(INFO) << outputs[0].matrix<float>();
  return 0;
}


```

command is 
`g++ -std=c++17 -I/home/wangchen/tensorflow/bazel-bin/tensorflow/include -L/home/wangchen/tensorflow/bazel-bin/tensorflow/ tf_example.cpp -o tftest -ltensorflow_framework -ltensorflow_cc`

After successfully compile my code, I got an error when I tried to run it :
```
2024-03-11 01:24:42.588892: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-11 01:24:42.588959: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-11 01:24:42.589806: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
```

### Standalone code to reproduce the issue

```
#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"

using namespace tensorflow;
using namespace tensorflow::ops;

int main() {
  Scope root = Scope::NewRootScope();
  // Matrix A = [3 2; -1 0]
  auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f} });
  // Vector b = [3 5]
  auto b = Const(root, { {3.f, 5.f} });
  // v = Ab^T
  auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));
  std::vector<Tensor> outputs;
  ClientSession session(root);
  // Run and fetch v
  TF_CHECK_OK(session.Run({v}, &outputs));
  // Expect outputs[0] == [19; -3]
  LOG(INFO) << outputs[0].matrix<float>();
  return 0;
}


```


### Relevant log output

```
2024-03-11 01:34:55.525804: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-11 01:34:55.525867: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-11 01:34:55.526735: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-11 01:34:55.597359: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-11 01:34:55.715017: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2256] 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...
2024-03-11 01:34:55.791239: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
2024-03-11 01:34:55.800049: I /home/wangchen/tfc++test/tf_example.cpp:21] 19
```
