1. 下载对应版本的TensorRT
首先去NVIDIA官网下载对应版本的TensorRT,LZ这里使用的是6.0.1版本
下载的是tar版本,按照官方文档,只要增加一下系统变量就行啦
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<TensorRT-${version}/lib>
2. 在tf中重新config(挺多坑的,找了好久才知道原因)
超级多could not find的问题:
Could not find any NvInferVersion.h matching version '6' in any subdirectory:
给出config对应的日志:
felaim@felaim-pc:~/Documents/software/tensorflow-r1.14$ ./configure
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.24.1 installed.
Please specify the location of python. [Default is /usr/bin/python]: /home/felaim/anaconda3/envs/tensorflow-gpu/bin/python
Found possible Python library paths:
/home/felaim/anaconda3/envs/tensorflow-gpu/lib/python3.7/site-packages
Please input the desired Python library path to use. Default is [/home/felaim/anaconda3/envs/tensorflow-gpu/lib/python3.7/site-packages]
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: n
No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.
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]: y
TensorRT support will be enabled for TensorFlow.
Could not find any NvInferVersion.h matching version '' in any subdirectory:
''
'include'
'include/cuda'
'include/*-linux-gnu'
'extras/CUPTI/include'
'include/cuda/CUPTI'
of:
'/home/felaim/intel/ipp/lib/intel64_lin'
'/lib/x86_64-linux-gnu'
'/usr'
'/usr/lib'
'/usr/lib/x86_64-linux-gnu'
'/usr/lib/x86_64-linux-gnu/libfakeroot'
'/usr/lib/x86_64-linux-gnu/mesa'
'/usr/lib/x86_64-linux-gnu/mesa-egl'
'/usr/local/cuda'
'/usr/local/cuda-10.1/targets/x86_64-linux/lib'
'/usr/local/cuda/extras/CUPTI/lib64'
'/usr/local/lib'
Asking for detailed CUDA configuration...
Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10]:
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]:
Please specify the TensorRT version you want to use. [Leave empty to default to TensorRT 5]: 6
Please specify the locally installed NCCL version you want to use. [Leave empty to use http://github.com/nvidia/nccl]:
Please specify the comma-separated list of base paths to look for CUDA libraries and headers. [Leave empty to use the default]: /usr/local/cuda,/usr/local/cuda/bin,/usr/local/cuda/lib64,/usr/local/cuda/include,/home/felaim/Documents/software/TensorRT-6.0.1.5,/usr/lib/x86_64-linux-gnu/
Found CUDA 10.1 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
Found cuDNN 7 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
Found TensorRT 6 in:
/home/felaim/Documents/software/TensorRT-6.0.1.5/lib
/home/felaim/Documents/software/TensorRT-6.0.1.5/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.
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: 5.2]:
Do you want to use clang as CUDA compiler? [y/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]:
Do you wish to build TensorFlow with MPI support? [y/N]:
No MPI support will be enabled for TensorFlow.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]:
Would you like to interactively configure ./WORKSPACE for Android builds? [y/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=monolithic # Config for mostly static monolithic build.
--config=gdr # Build with GDR support.
--config=verbs # Build with libverbs support.
--config=ngraph # Build with Intel nGraph support.
--config=numa # Build with NUMA support.
--config=dynamic_kernels # (Experimental) Build kernels into separate shared objects.
Preconfigured Bazel build configs to DISABLE default on features:
--config=noaws # Disable AWS S3 filesystem support.
--config=nogcp # Disable GCP support.
--config=nohdfs # Disable HDFS support.
--config=noignite # Disable Apache Ignite support.
--config=nokafka # Disable Apache Kafka support.
--config=nonccl # Disable NVIDIA NCCL support.
Configuration finished
最后只要按照之前编译tensorflow c++接口重新编译一遍即可!,参考LZ之前的博客https://blog.csdn.net/Felaim/article/details/100349318。
到处都是知识盲区!/(ㄒoㄒ)/~~
参考地址: