Tensorflow: TensoeRT的安装及编译(c++接口)

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ㄒ)/~~

参考地址:

  1. https://docs.nvidia.com/deeplearning/sdk/tensorrt-install-guide/index.html#installing-tar

  2. https://github.com/tensorflow/tensorflow/issues/33251

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Code::Blocks 是一个开源的集成开发环境(IDE),主要用于编写和调试C、C++和Fortran程序。如果 Code::Blocks 无法编译C程序,可能存在以下几个可能的原因: 1. 缺少C编译器:Code::Blocks 需要与C编译器一起使用才能编译C程序。确保已经安装了适当的C编译器,例如MinGW(Windows平台上的常见选择)或GCC(Linux平台上的默认编译器)。可以通过在Code::Blocks的设置中配置编译器路径来解决此问题。 2. 配置问题:在Code::Blocks中,需要正确配置编译器才能进行编译。检查Code::Blocks的编译器设置,确保已选择正确的编译器,并且路径设置正确。 3. 代码错误:如果代码中存在语法错误或逻辑错误,编译器将无法将其编译成可执行程序。在编译之前,请确保代码正确且没有错误。 4. 编译器版本不兼容:Code::Blocks可能不兼容特定版本的编译器。尝试使用不同的编译器版本或更新Code::Blocks版本,以解决此类问题。 5. 系统环境问题:某些系统环境可能会导致Code::Blocks无法编译C程序,例如缺少必要的库文件或配置错误。检查系统环境是否满足编译要求,并确保没有其他程序或设置干扰编译过程。 总之,如果Code::Blocks无法编译C程序,需要检查编译器的安装和配置,并确保代码正确且没有错误。如果问题仍然存在,可能需要考虑更换编译器或更新Code::Blocks版本。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值