当前位置: 首页 > news >正文

ubuntu20.04 安装TensorRT,解决依赖问题

1.下载Tensor RT对应的deb包

先要确保cuda和cudnn安装好,https://blog.csdn.net/qq_41246375/article/details/115597025

下载tensor RT,注意版本对应关系
https://developer.nvidia.com/nvidia-tensorrt-8x-download

2.安装

按照官方步骤
https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#downloading

安装 TensorRT 时可以选择以下安装选项;Debian 或 RPM 软件包、Python Wheel 文件、tar 文件或 zip 文件。
Debian 和 RPM 安装会自动安装任何依赖项,但是:

  • 需要sudo或root权限来安装
  • 对于 TensorRT 安装到哪个位置不灵活
  • 要求还使用 Debian 或 RPM 软件包安装CUDA Toolkit 和 cuDNN
  • 不允许同时安装多个 TensorRT 小版本

tar 文件提供了更大的灵活性,例如可以同时安装多个版本的 TensorRT。但是,需要确保已安装必要的依赖项,并且必须管理LD_LIBRARY_PATH 。有关详细信息,请参阅Tar 文件安装。windows仅支持zip安装

以上是官网提示,所以选择tar文件安装最为稳妥,deb安装则需要cuda和cudnn也是deb安装的,但一般cuda都是runfile安装。

Tar安装

  1. Download the TensorRT tar file that matches the CPU architecture and CUDA version you are using.
  2. Choose where you want to install TensorRT. This tar file will install everything into a subdirectory called
  3. TensorRT-8.x.x.x.
version="8.x.x.x"
arch=$(uname -m)
cuda="cuda-x.x"
tar -xzvf TensorRT-${version}.Linux.${arch}-gnu.${cuda}.tar.gz

Where:

  • 8.x.x.x is your TensorRT version
  • cuda-x.x is CUDA version 11.8 or 12.0

This directory will have sub-directories like lib, include, data, and so on.

ls TensorRT-${version}
bin  data  doc  graphsurgeon  include  lib  onnx_graphsurgeon  python  samples  targets  uff
  1. Add the absolute path to the TensorRT lib directory to the environment variable LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<TensorRT-${version}/lib>
  1. Install the Python TensorRT wheel file (replace cp3x with the desired Python version, for example, cp310 for Python 3.10).
cd TensorRT-${version}/python
python3 -m pip install tensorrt-*-cp3x-none-linux_x86_64.whl

Optionally, install the TensorRT lean and dispatch runtime wheel files:

python3 -m pip install tensorrt_lean-*-cp3x-none-linux_x86_64.whl
python3 -m pip install tensorrt_dispatch-*-cp3x-none-linux_x86_64.whl
  1. Install the Python UFF wheel file. This is only required if you plan to use TensorRT with TensorFlow in UFF format.
cd TensorRT-${version}/uffpython3 -m pip install uff-0.6.9-py2.py3-none-any.whl

Check the installation with:

which convert-to-uff
  1. Install the Python graphsurgeon wheel file.
cd TensorRT-${version}/graphsurgeonpython3 -m pip install graphsurgeon-0.4.6-py2.py3-none-any.whl
  1. Install the Python onnx-graphsurgeon wheel file.
cd TensorRT-${version}/onnx_graphsurgeonpython3 -m pip install onnx_graphsurgeon-0.3.12-py2.py3-none-any.whl
  1. Verify the installation:
    • Ensure that the installed files are located in the correct
      directories. For example, run the tree -d command to check whether
      all supported installed files are in place in the lib, include, data,
      and so on directories.

    • Build and run one of the shipped
      samples, for example, sampleMNIST in the installed directory. You
      should be able to compile and execute the sample without additional
      settings. For more information, refer to sampleMNIST.

    • The Python samples are in the samples/python directory.

为方便c++使用

sudo cp -r TensorRT-8.x.x.x /usr/local/

deb安装,不推荐

sudo dpkg -i nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-11.8_1.0-1_amd64.deb
sudo cp /var/nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-11.8/nv-tensorrt-local-D7BB1B18-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install tensorrtdpkg-query -W tensorrt	#查看安装结果
http://www.lryc.cn/news/233122.html

相关文章:

  • 你知道如何科学的学习吗?-关于个人成长的思考
  • Java学习之路 —— 多线程
  • 【云原生-Kurbernetes篇】K8s的存储卷/数据卷+PV与PVC
  • 二层、三层交换机之间到底有什么区别?
  • 【论文阅读】2736. 最大和查询-2023.11.17
  • 2. zk集群部署
  • 抖音快手判断性别、年龄自动关注脚本,按键精灵开源代码!
  • IDEA软件使用步骤
  • 设计模式-11-模板模式
  • 【技术分享】EIGRP stub实验
  • Python 爬虫 AES DES加密反爬
  • (论文阅读30/100)Convolutional Pose Machines
  • vue3实现数据大屏内数据向上滚动,鼠标进入停止滚动 vue3+Vue3SeamlessScroll
  • WPF显示3D图形
  • Xrdp+Cpolar实现远程访问Linux Kali桌面
  • 赚钱
  • Django command执行脚本
  • GLSL: Shader cannot be patched for instancing.
  • Django测试环境搭建及ORM查询(创建外键|跨表查询|双下划线查询 )
  • css 设置网页最小字体为12px
  • Failed to restart networking.service: Unit networking.service not found.
  • 基于单片机设计的水平仪(STC589C52+MPU6050)
  • 射频与微波综合测试仪-4958手持式微波综合测试仪
  • Redis内存淘汰机制
  • EXCEL——计算数据分散程度的相关函数
  • 详解如何使用Jenkins一键打包部署SpringBoot项目
  • 【JVM】内存区域划分、类加载机制(双亲委派模型图解)、垃圾回收(可达性分析、分代回收)
  • 解决 requests 2.28.x 版本 SSL 错误
  • hive数据质量规范
  • Jenkinsfile+Dockerfile前端vue自动化部署