網站首頁 編程語言 正文
服務器配置:
GPU:2080Ti
CUDA版本:cuda:11.3
driver version:450.57
1、部署環境配置:
(1)拉取鏡像并進入
docker pull adenialzz/mmdeploy
docker run --gpus all --name [鏡像名稱] -itd -p 物理機端口:容器端口 -v 本地地址:容器映射地址 --privileged=true --ipc=host [容器id] /bin/bash
docker exec -it [容器id] /bin/bash
(2)下載對應cuda版本的mmcv-full\torch\torchvision 并安裝
CUDA版本:11.3
mmcv-full: mmcv_full-1.4.8-cp38-cp38-manylinux1_x86_64.whl
TensorRT:TensorRT-8.4.1.5.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
torch:torch-1.10.0+cu113-cp38-cp38-linux_x86_64.whl
torchvision:torchvision-0.11.1+cu113-cp38-cp38-linux_x86_64.whl
pip install torch-1.10.0+cu113-cp38-cp38-linux_x86_64.whl
pip install torchvision-0.11.1+cu113-cp38-cp38-linux_x86_64.whl
pip install mmcv_full-1.4.8-cp38-cp38-manylinux1_x86_64.whl
其余需要資源:
ppl.cv/onnxruntime-linux-x64-1.8.1.tgz/third_party/pybind11/ cmake>=3.14/mmdeploy-0.4.0/mmdetection-2.22.0/TensorRT
(3)安裝和配置
安裝mmdetection
pip install
cd mmdetection-2.22.0
pip install -v -e .
安裝TensorRT
tar -xvf TensorRT-8.4.1.5.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
pip install TensorRT-8.4.1.5/python/tensorrt-8.4.1.5-cp38-none-linux_x86_64.whl
pip install TensorRT-8.4.1.5/onnx_graphsurgeon/onnx_graphsurgeon-0.3.12-py2.py3-none-any.whl
pip install TensorRT-8.4.1.5/graphsurgeon/graphsurgeon-0.4.6-py2.py3-none-any.whl
pip install TensorRT-8.4.1.5/uff/uff-0.6.9-py2.py3-none-any.whl
并在bashrc中完成變量添加:
export TENSORRT_DIR=/root/workspace/TensorRT-8.4.1.5:$TENSORRT_DIR
export LD_LIBRARY_PATH=/root/workspace/TensorRT-8.4.1.5/lib/:$LD_LIBRARY_PATH
編譯mmdeploy-0.4.0
-
TensorRT 自定義算子
cd ${MMDEPLOY_DIR} mkdir -p build && cd build cmake -DCMAKE_CXX_COMPILER=g++-9 -DMMDEPLOY_TARGET_BACKENDS=trt -DTENSORRT_DIR=${TENSORRT_DIR} -DCUDNN_DIR=${CUDNN_DIR} .. make -j$(nproc)
-
安裝 Model Converter
cd ${MMDEPLOY_DIR} pip install -e .
-
cuda + TensorRT編譯
cd ${MMDEPLOY_DIR} mkdir -p build && cd build cmake .. \ -DCMAKE_CXX_COMPILER=g++-9\ -DMMDEPLOY_BUILD_SDK=ON \ -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \ -DMMDEPLOY_TARGET_DEVICES="cuda;cpu" \ -DMMDEPLOY_TARGET_BACKENDS=trt \ -DMMDEPLOY_CODEBASES=all \ -Dpplcv_DIR=${PPLCV_DIR}/cuda-build/install/lib/cmake/ppl \ -DTENSORRT_DIR=${TENSORRT_DIR} \ -DCUDNN_DIR=${CUDNN_DIR} make -j$(nproc) && make install
出現上述圖片就是成功的標志
2、推理環境配置和測試
(1)加載mmdet2_5_tensorrt_inference.tar鏡像
(2)重新安裝TensorRT-8.4.1.5.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
(3)運行測試代碼
測試結果如下所示:
FP32:
FP16:
INT8:
mmdet-fp32 | trt_fp32 | trt_fp16 | trt_int8 | |
---|---|---|---|---|
trt加速 | 18.67 | 31.74 | 61.35 | 71.80 |
trt加速+后處理 | 9-10 | 15-16 | 17-19 | 17-19 |
3、Trouble Shooting
1、直接運行,報了cuda error ,說是torch版本不兼容
2、更新torch版本為1.7后
ImportError: cannot import name ‘_get_tensor_dim_size’ from ‘torch.onnx.symbolic_helper’ (/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py)
3、更新torch為1.11
ImportError: /opt/conda/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor7is_cudaEv
1/2/3解決方式:登錄torch官網,找到自己CUDA版本適配的torch/torchvision.
mmcv-full安裝方式也需要去mmcv-full官網查詢與之適配的cuda版本好,以防出錯。
4、ImportError: libnvinfer.so.8: cannot open shared object file: No such file or directory
解決方式:配置TensorRT的環境變量
–END–
原文鏈接:https://blog.csdn.net/caobin_cumt/article/details/125882499
- 上一篇:python logging模塊使用介紹
- 下一篇:微信小程序--動態設置導航欄顏色
相關推薦
- 2022-05-03 SQL?Server查詢某個字段在哪些表中存在_MsSql
- 2022-09-04 深入了解Golang包的獲取方法_Golang
- 2022-11-04 Android實現簡易秒表功能_Android
- 2022-08-10 python中ThreadPoolExecutor線程池和ProcessPoolExecutor進程
- 2022-07-06 R語言可視化開發forestplot根據分組設置不同顏色_R語言
- 2022-09-16 Firewalld防火墻安全防護_網絡安全
- 2023-11-15 latex報錯:Misplaced alignment tab character &. .
- 2022-11-21 C#基礎知識之字符串和正則表達式_C#教程
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支