日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

ubuntu18.04+cuda10.2+tensorrt8.4.1.5配置安裝

作者:xuan_gxi 更新時(shí)間: 2022-07-26 編程語言

下載tensorrt8.4.1.5

https://developer.nvidia.com/nvidia-tensorrt-8x-download
在這里插入圖片描述`

tar -zxvf TensorRT-8.4.1.5.Linux.x86_64-gnu.cuda-10.2.cudnn8.4.tar.gz
`
放在主目錄下面

添加環(huán)境變量

sudo gedit ~/.bashrc
export LD_LIBRARY_PATH=/home/xuanxi/TensorRT-8.4.1.5/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/home/xuanxi/TensorRT-8.4.1.5/lib::$LIBRARY_PATH
source ~/.bashrc

安裝tensorrt的python包。進(jìn)入tensorrt壓縮之后的文件夾,然后進(jìn)入里面的python文件夾

cd ./TensorRT-8.4.1.5/python

在這里插入圖片描述python文件夾里面有很多版本,使用pip安裝自己對(duì)應(yīng)的python版本
進(jìn)入虛擬環(huán)境(!!!)

source activate torch1.7
pip install tensorrt-8.4.1.5-cp37-none-linux_x86_64.whl
(torch1.7) xuanxi@xuanxi-MS-7C02:~/TensorRT-8.4.1.5/python$ python
Python 3.7.9 (default, Aug 31 2020, 12:42:55) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt
>>> tensorrt.__version__

在這里插入圖片描述這就安裝成功了?。?!

可以順便安裝其他兩個(gè)包
1)安裝 uff 包

cd ../uff    # 切換到 uff 文件夾
pip install uff-0.6.9-py2.py3-none-any.whl 

測(cè)試是否安裝成功:

which convert-to-uff  # 會(huì)輸出安裝路徑

2)安裝 graphsurgen 包

cd ../graphsurgeon     # 切換到 graphsurgeon 文件夾
pip install graphsurgeon-0.3.2-py2.py3-none-any.whl

安裝 Polygraphy,或者通過 TensorRT/tools/Polygraphy 源碼安裝

python -m pip install colored polygraphy --extra-index-url https://pypi.ngc.nvidia.com

運(yùn)行 ONNX 模型,保存輸入輸出

polygraphy run model_4.onnx --onnxrt --val-range [0,1] --save-inputs onnx_inputs.json --save-outputs onnx_outputs.json

運(yùn)行 TRT 模型,載入 ONNX 輸入輸出,對(duì)比輸出的相對(duì)誤差與絕對(duì)誤差

polygraphy run rvm_mobilenetv3_fp32_sim_modified.engine --model-type engine --trt --load-inputs onnx_inputs.json --load-outputs onnx_outputs.json --rtol 1e-3 --atol 1e-3

使用上面生成的 model.onnx 構(gòu)建 TensorRT 引擎,使用 FP32 精度同時(shí)在 TensorRT 和 onnxruntime 中運(yùn)行

輸出所有層的計(jì)算結(jié)果作對(duì)比

polygraphy run model_4.onnx
–onnxrt --trt
–workspace 100000000
–save-engine=model_FP32_MarkAll.plan
–atol 1e-3 --rtol 1e-3
–verbose
–onnx-outputs mark all
–trt-outputs mark all
–trt-min-shapes ‘x:0:[1,1,28,28]’
–trt-opt-shapes ‘x:0:[4,1,28,28]’
–trt-max-shapes ‘x:0:[1,28,28]’
–input-shapes ‘x:0:[1,80,300]’
> result-run-FP32-MarkAll.txt

原文鏈接:https://blog.csdn.net/xuan_gap/article/details/125946440

欄目分類
最近更新