目录
1 jetson-ffmpeg的编译安装与配置--用来做视频编码、视频解码
2 CV-CUDA库的编译安装与配置--用来做图像缩放、裁剪、色域转换
3 cuda cudnn TensorRT相关库的拷贝与配置
3.1将cuda cudnn TensorRT相关的头文件拷贝到工程中
3.2 将cuda cudnn TensorRT相关的库拷贝到/data/chw/compute_lib/lib/jetson_lib
4 cuda_utils库编译
5 算法推理库trteng_exp编译安装和配置
5.1 报错 trtNet_v2.cpp:1:10: fatal error: spdlog/fmt/fmt.h: No such file or directory
6 算法模型转换库model2trt_v2编译安装和配置
6.1 prot_parse_convert.cpp:7:10: fatal error: caffe/caffe.pb.h: No such file or directory
6.2 error: invalid conversion from ‘const char*’ to ‘const uint8_t*’ {aka ‘const unsigned char*’}
6.3 error: no matching function for call to ‘google::protobuf::internal::InternalMetadata::unknown_fields() const
6.4 源码编译安装protobuf
6.5 caffe/caffe.pb.h:13:2: error: #error "This file was generated by a newer version of protoc which i
7 build_all.sh一键编译cuda_utils trteng_exp model2trt_v2
8 测试model2trt_v2转模型
9 拷贝所有的计算库到./nvstream/3rdparty/jetson/compute/lib/aarch64
参考文献:
记录下将CNStream流处理多路并发Pipeline框架适配到NVIDIA Jetson AGX Orin的过程,以及过程中遇到的问题,我的jetson盒子是用jetpack5.1.3重新刷机之后的,这是系列博客的第一篇。
1 jetson-ffmpeg的编译安装与配置--用来做视频编码、视频解码
在jetson AGX Orin上会选择用jetson-ffmpeg做视频编解码以及图像处理工作,其中jetson-ffmpeg的编译安装见如下博客
在NVIDIA Jetson AGX Orin中使用jetson-ffmpeg调用硬件编解码加速处理-CSDN博客
编译安装完之后,相应的库文件在/usr/local/lib/,相应的头文件在/usr/local/include/
使用如下命令将编译号的jetson-ffmpeg拷贝到我的工程的./nvstream/3rdparty/ffmpeg中
cp -rf /usr/local/lib/lib* /data/chw/nvstream/3rdparty/ffmpeg/lib/aarch64/
cp -rf /usr/local/include/* /data/chw/nvstream/3rdparty/ffmpeg/include/
这样之后,工程里面的3rdparty/config_lib_aarch64.sh脚本内容需要修改,把脚本中ffmpeg相关的内容修改如下
#----------------------------------
# ffmpeg
#----------------------------------
cd ${root}/ffmpeg/lib/linux_lib
\cp ../${arch}/* .
ln -snf libavcodec.so.58.134.100 libavcodec.so.58
ln -snf libavcodec.so.58 libavcodec.so
ln -snf libavdevice.so.58.13.100 libavdevice.so.58
ln -snf libavdevice.so.58 libavdevice.so
ln -snf libavfilter.so.7.110.100 libavfilter.so.7
ln -snf libavfilter.so.7 libavfilter.so
ln -snf libavformat.so.58.76.100 libavformat.so.58
ln -snf libavformat.so.58 libavformat.so
ln -snf libavutil.so.56.70.100 libavutil.so.56
ln -snf libavutil.so.56 libavutil.so
ln -snf libswresample.so.3.9.100 libswresample.so.3
ln -snf libswresample.so.3 libswresample.so
ln -snf libswscale.so.5.9.100 libswscale.so.5
ln -snf libswscale.so.5 libswscale.so
ln -snf libnvmpi.so.1.0.0 libnvmpi.so.1
ln -snf libnvmpi.so.1 libnvmpi.so
2 CV-CUDA库的编译安装与配置--用来做图像缩放、裁剪、色域转换
CV-CUDA库的编译和安装见如下博客:NVIDIA Jetson AGX Orin源码编译安装CV-CUDA-CSDN博客
编译安装完之后,用如下命令将cv-cuda相关的库和头文件拷贝到工程中
cp -rf /opt/nvidia/cvcuda0/include/* /data/chw/nvstream/3rdparty/jetson/cvcuda/include/
cp -rf /opt/nvidia/cvcuda0/lib/aarch64-linux-gnu/lib* /data/chw/nvstream/3rdparty/jetson/cvcuda/lib/aarch64/
同样修改库的配置脚本3rdparty/config_lib_aarch64.sh,修改的部分内容如下
#----------------------------------
# jetson: cv-cuda
#----------------------------------
cd ${root}/jetson/cvcuda/lib/linux_lib
\cp ../${arch}/* .
ln -snf libcvcuda.so.0.10.1 libcvcuda.so.0
ln -snf libcvcuda.so.0 libavcodec.so
ln -snf libnvcv_types.so.0.10.1 libnvcv_types.so.0
ln -snf libnvcv_types.so.0 libavdevice.so
3 cuda cudnn TensorRT相关库的拷贝与配置
由于用jetpack5.1.3刷机之后,cuda cudnn TensorRT相关的库版本和之前相比有更新,所以要把cuda cudnn TensorRT相关的库拷贝到我的工程下面。为什么不直接用/usr/local下面的库,这是为了以后如果工程迁移到别的盒子上,那么可以把这些库直接考过去,这样系统路径下的库版本不一样也可以用。
3.1将cuda cudnn TensorRT相关的头文件拷贝到工程中
这个省点事,不拷贝了,到时候makefile直接去/usr/local/cuda/include这种默认路径下找吧,反正我最终的工程代码不需要cuda这些的头文件。
3.2 将cuda cudnn TensorRT相关的库拷贝到/data/chw/compute_lib/lib/jetson_lib
用如下命令拷贝cuda相关库
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcublasLt.so.11.6.6.84 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcublas.so.11.6.6.84 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcudart.so.11.4.298 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcurand.so.10.2.5.297 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libnvrtc-builtins.so.11.4.300 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/local/cuda-11.4/targets/aarch64-linux/lib/libnvrtc.so.11.4.300 /data/chw/compute_lib/lib/jetson_lib/
用下面的命令拷贝cudnn相关库
cp /usr/lib/aarch64-linux-gnu/libcudnn_cnn_infer.so.8.6.0 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/libcudnn.so.8.6.0 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/libcudnn_ops_infer.so.8.6.0 /data/chw/compute_lib/lib/jetson_lib/
用下面的命令拷贝TensorRT相关的库
cp /usr/lib/aarch64-linux-gnu/libnvinfer.so.8.5.2 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/libnvinfer_plugin.so.8.5.2 /data/chw/compute_lib/lib/jetson_lib/
其他相关库的拷贝,下面的库在后面也会用到,也拷贝过去
cp /usr/lib/aarch64-linux-gnu/tegra/libnvdla_compiler.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvos.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvdla_runtime.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libcuda.so.1 /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvrm_host1x.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvrm_mem.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvsocsys.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvrm_gpu.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvrm_sync.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvrm_chip.so /data/chw/compute_lib/lib/jetson_lib/
cp /usr/lib/aarch64-linux-gnu/tegra/libnvsciipc.so /data/chw/compute_lib/lib/jetson_lib/
在lib/config_lib_jetson.sh里面之前并没有增加cuda相关库的软链接命令,因为之前jetson上都是直接去的/usr/local/cuda这种默认路径下找的库,但是这次我是把这些库拷贝到工程中了,所以lib/config_lib_jetson.sh需要增加这些东西,增加内容如下:
#----------------------------------
#Specific lib for GPU
#----------------------------------
#1> cuda
ln -snf libcublas.so.11.6.6.84 libcublas.so.11
ln -snf libcublas.so.11 libcublas.so
ln -snf libcublasLt.so.11.6.6.84 libcublasLt.so.11
ln -snf libcublasLt.so.11 libcublasLt.so
ln -snf libcudart.so.11.4.298 libcudart.so.11.0
ln -snf libcudart.so.11.0 libcudart.so.11
ln -snf libcudart.so.11 libcudart.so
ln -snf libcurand.so.10.2.5.297 libcurand.so.10
ln -snf libcurand.so.10 libcurand.so
ln -snf libnvrtc.so.11.4.300 libnvrtc.so.11
ln -snf libnvrtc.so.11 libnvrtc.so
ln -snf libnvrtc-builtins.so.11.4.300 libnvrtc-builtins.so.11.4
ln -snf libnvrtc-builtins.so.11.4 libnvrtc-builtins.so.11
ln -snf libnvrtc-builtins.so.11 libnvrtc-builtins.so
ln -snf libcudnn_ops_infer.so.8.6.0 libcudnn_ops_infer.so.8
ln -snf libcudnn_ops_infer.so.8 libcudnn_ops_infer.so
ln -snf libcudnn_cnn_infer.so.8.6.0 libcudnn_cnn_infer.so.8
ln -snf libcudnn_cnn_infer.so.8 libcudnn_cnn_infer.so
ln -snf libcudnn.so.8.6.0 libcudnn.so.8
ln -snf libcudnn.so.8 libcudnn.so
#2> TensorRT
ln -snf libnvinfer.so.8.5.2 libnvinfer.so.8
ln -snf libnvinfer.so.8 libnvinfer.so
ln -snf libnvinfer_plugin.so.8.5.2 libnvinfer_plugin.so.8
ln -snf libnvinfer_plugin.so.8 libnvinfer_plugin.so
然后执行以下这个脚本去/data/chw/compute_lib/lib目录下
sh config_lib_jetson.sh
4 cuda_utils库编译
然后由于我把cuda cudnn这些库拷贝过来了,那么comp_nvidia/cuda_utils/Makefile_jetson中cuda cudnn这些库的路径我要修改一下,如下所示,删除默认路径
#LIBRARY_PATH := /usr/local/cuda/lib64
LIBRARY_PATH := ../../lib/linux_lib
这样他就直接去我自己的路径下找库了。然后直接用下面的命令编译
make -f Makefile_jetson clean; make -f Makefile_jetson
然后ldd看一下,确实是找的我自己路径下的了,不是/usr/local/cuda-11.4/targets/aarch64-linux/lib下的了。
5 算法推理库trteng_exp编译安装和配置
和上面一样,由于我把cuda cudnn这些库拷贝过来了,那么comp_nvidia/trteng_exp/Makefile_jetson中cuda cudnn这些库的路径我要修改一下,如下所示,删除默认路径
#LIBRARY_PATH := ../../lib/linux_lib /usr/local/cuda/lib64 /usr/lib/aarch64-linux-gnu/tegra
LIBRARY_PATH := ../../lib/linux_lib
这样他就直接去我自己的路径下找库了。然后直接用下面的命令编译。
make -f Makefile_jetson clean; make -f Makefile_jetson
用上面的命令进行编译,
5.1 报错 trtNet_v2.cpp:1:10: fatal error: spdlog/fmt/fmt.h: No such file or directory
这是因为compute_lib/include这个头文件文件夹没有放到/data/chw/compute_lib里面,上传到盒子上,
然后再次编译
6 算法模型转换库model2trt_v2编译安装和配置
model2trt_v2除了依赖前面的cuda cudnn TensorRT那一堆库之外,在comp_nvidia/model2trt_v2/lib路径下的libnvonnxparser.so.8.0.1和libnvparsers.so.8.0.1要替换成新版本,这里cp的时候加上了-d,软链接也一并拷贝过去了,
cp -drf /usr/lib/aarch64-linux-gnu/libnvparsers* /data/chw/compute_lib/comp_nvidia/model2trt_v2/lib/
cp -drf /usr/lib/aarch64-linux-gnu/libnvonnxparser* /data/chw/compute_lib/comp_nvidia/model2trt_v2/lib/
修改makeifle
## used include librarys file path
#LIBRARY_PATH := ../../lib/linux_lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/tegra /usr/local/cuda/targets/aarch64-linux/lib
LIBRARY_PATH := ../../lib/linux_lib ./lib
然后用下面的命令编译
make -f Makefile_jetson clean; make -f Makefile_jetson -j8
然后报错
6.1 prot_parse_convert.cpp:7:10: fatal error: caffe/caffe.pb.h: No such file or directory
prot_parse_convert.cpp:7:10: fatal error: caffe/caffe.pb.h: No such file or directory
7 | #include "caffe/caffe.pb.h"
解决方法
sudo apt install -y protobuf-compiler
protoc caffe.proto --proto_path=./ --cpp_out=./caffe
6.2 error: invalid conversion from ‘const char*’ to ‘const uint8_t*’ {aka ‘const unsigned char*’}
error: invalid conversion from ‘const char*’ to ‘const uint8_t*’ {aka ‘const unsigned char*’} [-fpermissive]
78 | const IBlobNameToTensor* blobNameToTensor = parser->parseBuffers(cleaned_proto.data(),cleaned_proto.size(),
继续编译报上面的错误,这种错误看着就像是版本更新导致的错误,我直接修改代码强制类型转换
const IBlobNameToTensor* blobNameToTensor = parser->parseBuffers(reinterpret_cast<const uint8_t*>(cleaned_proto.data()),cleaned_proto.size(),
reinterpret_cast<const uint8_t*>(model_data.data()),model_data.size(),
*network,
DataType::kFLOAT);
6.3 error: no matching function for call to ‘google::protobuf::internal::InternalMetadata::unknown_fields() const
再次编译刷屏报类似上面两个这样的错误。
这些错误看着都是protobuf的错误,问题原因是我前面用sudo apt install -y protobuf-compiler安装的protobug太老了,需要20版本以上的。
所以先卸载掉前面安装的,然后改为源码编译安装protobuf。
sudo apt remove protobuf-compiler
6.4 源码编译安装protobuf
首先安装依赖
sudo apt-get install autoconf automake libtool curl make g++ unzip
然后下载、编译、安装
git clone --branch v23.0 https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/protobuf ..
make -j$(nproc)
sudo make install
配置环境变量,编辑/etc/profile,vim /etc/profile在里面增加如下内容
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib/
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/protobuf/lib/
export PATH=$PATH:/usr/local/protobuf/bin/
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/protobuf/include/
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/protobuf/include/
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/
然后
source /etc/profile
然后
6.5 caffe/caffe.pb.h:13:2: error: #error "This file was generated by a newer version of protoc which i
继续用下面命令编译model2trt_v2
protoc caffe.proto --proto_path=./ --cpp_out=./caffe
make -f Makefile_jetson clean; make -f Makefile_jetson -j8
报上面的错误,这错误还是protoc的版本问题,其实上面不需要源码编译安装protoc,在./compute_lib/bin/jetson目录下是有这个工具和库的,只是我没有把他传到盒子上,现在把这个上传到盒子上,
然后把上面vim /etc/profile的内容删掉。
然后不这样单独编译了,用build_all.sh一键编译脚本进行编译。
7 build_all.sh一键编译cuda_utils trteng_exp model2trt_v2
使用build_all.sh前,要把某些内容注释掉,因为这次在jetson盒子上并不是所有东西都需要编译。
另外库的版本也需要修改。
完整版的build_all.sh备份如下
#!/bin/bash
#出现错误即退出执行
set -e
root_dir=$(dirname "$PWD")
cd ${root_dir}
function enable_release_type() {
device=$1
if [ "$device" = "mlu" ]; then
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile_mlu
elif [ "$device" = "mlu_arm" ]; then
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile_mlu_arm
elif [ "$device" = "jetson" ]; then
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile_jetson
elif [ "$device" = "acl_arm" ]; then
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile_acl_arm
elif [ "$device" = "bm" ]; then
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile_bm
else
sed -i "s/.*\(DBG_ENABLE\s*:=\s*\).*\$/\10/" Makefile
fi
}
function build() {
device=$1
#设置为release版本
enable_release_type $device
if [ "$device" = "mlu" ]; then
make -f Makefile_mlu clean
make -f Makefile_mlu -j8
elif [ "$device" = "mlu_arm" ]; then
make -f Makefile_mlu_arm clean
make -f Makefile_mlu_arm -j8
elif [ "$device" = "jetson" ]; then
make -f Makefile_jetson clean
make -f Makefile_jetson -j8
elif [ "$device" = "acl_arm" ]; then
make -f Makefile_acl_arm clean
make -f Makefile_acl_arm -j8
elif [ "$device" = "bm" ]; then
make -f Makefile_bm clean
make -f Makefile_bm -j8
elif [ "$device" = "gpu_arm" ]; then
make -f Makefile_gpu_arm clean
make -f Makefile_gpu_arm -j8
else
make clean
make -j8
fi
}
function build_caffe() {
device=$1
if [ "$device" = "mlu" ]; then
#设置NEUWARE
export NEUWARE_HOME=${root_dir}/comp_cambricon/include/neuware
chmod +x -R ${root_dir}/comp_cambricon/include/neuware/bin
#设置protoc目录
export PATH=$PATH:${root_dir}/bin/x64
chmod +x -R ${root_dir}/bin/x64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${root_dir}/bin/x64:${root_dir}/lib/linux_lib
ln -snf ${root_dir}/lib/linux_lib ${root_dir}/comp_cambricon/include/neuware/lib64
cd ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/scripts
chmod +x ./*.sh
#./build_caffe_mlu270_cambricon_release.sh
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/lib/*.a ${root_dir}/comp_cambricon/cafl_sdk/lib
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/tools/caffe ${root_dir}/distribute/bin/mlu
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/tools/generate_quantized_pt ${root_dir}/distribute/bin/mlu
elif [ "$device" = "mlu_arm" ]; then
#设置NEUWARE
echo "1..."
export NEUWARE_HOME=${root_dir}/comp_cambricon/include/neuware
chmod +x -R ${root_dir}/comp_cambricon/include/neuware/bin
echo "2..."
#设置protoc目录
export PATH=$PATH:${root_dir}/bin/x64
chmod +x -R ${root_dir}/bin/x64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${root_dir}/bin/x64:${root_dir}/lib/linux_lib
ln -snf ${root_dir}/lib/linux_lib ${root_dir}/comp_cambricon/include/neuware/lib64
cd ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/scripts
echo "3..."
chmod +x ./*.sh
#./build_caffe_mlu270_cambricon_release.sh
#echo "4..."
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/lib/*.a ${root_dir}/comp_cambricon/cafl_sdk/lib
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/tools/caffe ${root_dir}/distribute/bin/mlu_arm
#\cp ${root_dir}/comp_cambricon/caffe_mlu/caffe/src/caffe/build/tools/generate_quantized_pt ${root_dir}/distribute/bin/mlu_arm
else
#设置protoc目录
if [ "$device" = "jetson" ]; then
export PATH=$PATH:${root_dir}/bin/jetson
chmod +x -R ${root_dir}/bin/jetson
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${root_dir}/bin/jetson:${root_dir}/lib/linux_lib
export CUDA_DIR=/usr/local/cuda
#protoc ${root_dir}/comp_nvidia/caffe_gcs/src/caffe/proto/caffe.proto --proto_path=${root_dir}/comp_nvidia/caffe_gcs/src/caffe/proto --cpp_out=${root_dir}/caffe_gcs/src/caffe/proto
#cd ${root_dir}/comp_nvidia/caffe_gcs
#make -f Makefile_jetson clean
#make -f Makefile_jetson -j8
elif [ "$device" = "gpu_arm" ]; then
export PATH=$PATH:${root_dir}/bin/gpu_arm
chmod +x -R ${root_dir}/bin/gpu_arm
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${root_dir}/bin/gpu_arm:${root_dir}/lib/linux_lib
export CUDA_DIR=/usr/local/cuda
else
export PATH=$PATH:${root_dir}/bin/x64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${root_dir}/bin/x64:${root_dir}/lib/linux_lib
export CUDA_DIR=${root_dir}/comp_nvidia/include/cuda
chmod +x -R ${root_dir}/bin/x64
chmod +x -R ${root_dir}/comp_nvidia/include/cuda/bin
chmod +x -R ${root_dir}/comp_nvidia/include/cuda/nvvm/bin
#设置cudnn包含文件,只针对gpu,jetson不使用此配置
cd ${root_dir}/comp_nvidia/include/cudnn
chmod +x config_cudnn.sh
./config_cudnn.sh
#protoc ${root_dir}/comp_nvidia/caffe_gcs/src/caffe/proto/caffe.proto --proto_path=${root_dir}/comp_nvidia/caffe_gcs/src/caffe/proto --cpp_out=${root_dir}/comp_nvidia/caffe_gcs/src/caffe/proto
#cd ${root_dir}/comp_nvidia/caffe_gcs
#make clean
#make -j
fi
#\cp ${root_dir}/comp_nvidia/caffe_gcs/.build_release/lib/*.a ${root_dir}/comp_nvidia/cafl_sdk/lib
fi
}
function config_lib() {
device=$1
if [ "$device" = "mlu" ]; then
chmod +x config_lib_mlu.sh
./config_lib_mlu.sh
elif [ "$device" = "mlu_arm" ]; then
chmod +x config_lib_mlu_arm.sh
./config_lib_mlu_arm.sh
elif [ "$device" = "jetson" ]; then
chmod +x config_lib_jetson.sh
./config_lib_jetson.sh
elif [ "$device" = "acl_arm" ]; then
chmod +x config_lib_acl_arm.sh
./config_lib_acl_arm.sh
elif [ "$device" = "bm" ]; then
chmod +x config_lib_bm.sh
./config_lib_bm.sh
elif [ "$device" = "gpu_arm" ]; then
chmod +x config_lib_gpu_arm.sh
./config_lib_gpu_arm.sh
else
chmod +x config_lib_gpu.sh
./config_lib_gpu.sh
fi
}
#build all services and libraries
function build_all(){
device=$1
echo "开始配置依赖库..."
cd ${root_dir}/lib
config_lib $device
echo "**********完成依赖库配置**********"
echo
: '
#不再使用caffe引擎
#if [ "$device" != "mlu_arm" ] && [ "$device" != "acl_arm" ]; then
echo "1)开始编译caffe..."
build_caffe $device
echo "**********完成编译caffe**********"
echo
#echo "2)开始编译cafl_sdk..."
#cd ${root_dir}/cafl_sdk
#build $device
#echo "**********完成编译cafl_sdk**********"
#echo
else
echo "1)检测到device非需要caffe框架,caffe编译跳过..."
echo "---------------------------------------------"
echo
fi
'
if [ "$device" == "mlu" ] || [ "$device" == "mlu_arm" ]; then
echo "3)开始编译cnrteng_exp..."
cd ${root_dir}/comp_cambricon/cnrteng_exp
build $device
echo "**********完成编译cnrteng_exp**********"
echo
elif [ "$device" == "acl_arm" ]; then
echo "3)开始编译acleng_exp..."
cd ${root_dir}/comp_ascend/acleng_exp
build $device
echo "**********完成编译acleng_exp**********"
echo
echo "4)开始编译acllite..."
cd ${root_dir}/comp_ascend/acllite
build $device
echo "**********完成编译acllite**********"
echo
elif [ "$device" == "bm" ]; then
echo "3)开始编译bmrteng_exp..."
cd ${root_dir}/comp_bitmain/bmrteng_exp
build $device
echo "**********完成编译bmrteng_exp**********"
echo
elif [ "$device" == "gpu_arm" ]; then
build_caffe $device
echo "3)开始编译cuda_utils..."
cd ${root_dir}/comp_nvidia/cuda_utils
build $device
echo "**********完成编译cuda_utils**********"
echo
echo "4)开始编译trteng_exp..."
cd ${root_dir}/comp_nvidia/trteng_exp
build $device
echo "**********完成编译trteng_exp**********"
echo
echo "5)开始编译model2trt_v2..."
cd ${root_dir}/comp_nvidia/model2trt_v2
ln -snf $(pwd)/lib_gpu_arm/libnvparsers.so.8.0.1 $(pwd)/lib_gpu_arm/libnvparsers.so.8
ln -snf $(pwd)/lib_gpu_arm/libnvparsers.so.8 $(pwd)/lib_gpu_arm/libnvparsers.so
ln -snf $(pwd)/lib_gpu_arm/libnvonnxparser.so.8.0.1 $(pwd)/lib_gpu_arm/libnvonnxparser.so.8
ln -snf $(pwd)/lib_gpu_arm/libnvonnxparser.so.8 $(pwd)/lib_gpu_arm/libnvonnxparser.so
protoc caffe.proto --proto_path=./ --cpp_out=./caffe
build $device
echo "**********完成编译model2trt_v2**********"
echo
else
build_caffe $device
echo "3)开始编译cuda_utils..."
cd ${root_dir}/comp_nvidia/cuda_utils
build $device
echo "**********完成编译cuda_utils**********"
echo
echo "4)开始编译trteng_exp..."
cd ${root_dir}/comp_nvidia/trteng_exp
build $device
echo "**********完成编译trteng_exp**********"
echo
echo "5)开始编译model2trt_v2..."
cd ${root_dir}/comp_nvidia/model2trt_v2
ln -snf $(pwd)/lib/libnvparsers.so.8.5.2 $(pwd)/lib/libnvparsers.so.8
ln -snf $(pwd)/lib/libnvparsers.so.8 $(pwd)/lib/libnvparsers.so
ln -snf $(pwd)/lib/libnvonnxparser.so.8.5.2 $(pwd)/lib/libnvonnxparser.so.8
ln -snf $(pwd)/lib/libnvonnxparser.so.8 $(pwd)/lib/libnvonnxparser.so
protoc caffe.proto --proto_path=./ --cpp_out=./caffe
build $device
echo "**********完成编译model2trt_v2**********"
echo
fi
echo "10)开始编译cfldwp2..."
#cd ${root_dir}/cfldwp2
#build $device
echo "**********完成编译cfldwp2**********"
echo
echo "<----------完成编译[${device}]设备上的[计算]库---------->"
}
case "$1" in
-h|--help)
echo "Usage: $0 [option...]"
echo "-h, --help for help information"
echo "-g, --gpu build for gpu device"
echo "-j, --jetson build for jetson arch"
echo "-m, --mlu build for mlu device"
echo "-ma, --mlu_arm build for mlu_arm device"
echo "-aa, --acl_arm build for acl_arm device"
echo "-b, --bm build for bm device"
echo "-ga, --gpu_arm build for gpu_arm device"
;;
-g|--gpu)
echo
echo
echo "<----------start building for [gpu] device---------->"
echo
build_all
;;
-j|--jetson)
echo
echo
echo "<----------start building for [jetson] device---------->"
echo
build_all jetson
;;
-m|--mlu)
echo
echo
echo "<----------start building for [mlu] device---------->"
echo
build_all mlu
;;
-ma|--mlu_arm)
echo
echo
echo "<----------start building for [mlu_arm] device---------->"
echo
build_all mlu_arm
;;
-aa|--acl_arm)
echo
echo
echo "<----------start building for [acl_arm] device---------->"
echo
build_all acl_arm
;;
-b|--bm)
echo
echo
echo "<----------start building for [bm] device---------->"
echo
build_all bm
;;
-ga|--gpu_arm)
echo
echo
echo "<----------start building for [gpu_arm] device---------->"
echo
build_all gpu_arm
;;
*)
echo "Please use $0 -h|--help for more information"
esac
exit 0
8 测试model2trt_v2转模型
export LD_LIBRARY_PATH=/data/chw/compute_lib/lib/linux_lib/:$LD_LIBRARY_PATH
./model2trt_v2 1 ./model/yolov5_pcb_dynamic
测试下转模型,转成功了。
9 拷贝所有的计算库到./nvstream/3rdparty/jetson/compute/lib/aarch64
cp /data/chw/compute_lib/distribute/lib/jetson_lib/libcuda_utils.so /data/chw/nvstream/3rdparty/jetson/compute/lib/aarch64/
cp /data/chw/compute_lib/distribute/lib/jetson_lib/libtrteng_exp.so /data/chw/nvstream/3rdparty/jetson/compute/lib/aarch64/
下一篇博客开始写代码;
参考文献:
在NVIDIA Jetson AGX Orin中使用jetson-ffmpeg调用硬件编解码加速处理-CSDN博客
NVIDIA Jetson AGX Orin源码编译安装CV-CUDA-CSDN博客
https://github.com/Cambricon/CNStream
https://github.com/Cambricon/easydk/blob/master/samples/simple_demo/common/video_decoder.cpp
aclStream流处理多路并发Pipeline框架中 视频解码 代码调用流程整理、类的层次关系整理、回调函数赋值和调用流程整理-CSDN博客
aclStream流处理多路并发Pipeline框架中VEncode Module代码调用流程整理、类的层次关系整理、回调函数赋值和调用流程整理-CSDN博客
FFmpeg/doc/examples at master · FFmpeg/FFmpeg · GitHub
https://github.com/CVCUDA/CV-CUDA
如何使用FFmpeg的解码器—FFmpeg API教程 · FFmpeg原理
C++ API — CV-CUDA Beta documentation (cvcuda.github.io)