1.目的:TensorRT_v6.0.1 2.编译环境准备:
(1) cuda-10.0 + cuDNN-7.6
CMake >= v3.13若本机CMake<v3.13,则可以搭建conda 环境,在conda 环境里安装CMake=3.15,并记录路径如:/media/data1/3rdtool/anaconda3/envs/libtorchcpp/bin/cmake
(2)默认 cuda-10.0 和 cuDNN-7.6安装的比较熟悉了;
3.下载TensorRT-6.0.1.5,解压路径:/xx/data11/3rdparty/TensorRT-6.0.1.5/lib
4.在CMakeLists.txt中project()上方添加:
set(CMAKE_CUDA_COMPILER /usr/local/cuda-10.0/bin/nvcc)
否则会报错:
CMake cannot find CUDA: "Could not find cmake module file: CMakeDetermineCUDACompiler.cmake"
5.源码clone
git clone -b master https://github.com/nvidia/TensorRT TensorRT
cd TensorRT
切换分支:
git tag
git checkout v6.0.1
git submodule update --init --recursive
6.习惯使用clion打开代码:
(1) 在file->setting->build->cmake,在cmake options中写入:
-DTRT_LIB_DIR=/xx/data11/3rdparty/TensorRT-6.0.1.5/lib
(2) 在file->setting->build->Toolchains, 在Cmake选择:
/media/data1/3rdtool/anaconda3/envs/libtorchcpp/bin/cmake
(3)编译,待编译完成把*.so库放入新建文件夹lib中
/xx /TensorRT/lib
(4)(可选)添加环境变量:Run/Debug Configuration ----->Environment variables:
LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:/xx/TensorRT/lib
7.然后可以快乐的build运行了。
|