> ## Content Index
> Fetch the complete content index at: https://yinguobing.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# 以Tar包的方式安装TensorRT
- URL: https://yinguobing.com/blog/install-tensorrt-with-tar-file/
- Published: 2022-05-22T03:16:25.000Z
- Updated: 2022-05-22T03:31:33.000Z
- Description: 准备TensorRT的C++环境
- Author: 尹国冰
- Tags: 新手入门

### 准备工作

TensorRT依赖CUDA与cuDNN，具体的版本信息可以通过官方给出的支持矩阵找到：

[Support Matrix :: NVIDIA Deep Learning TensorRT DocumentationThese support matrices provide a look into the supported platforms, features, and hardware capabilities of the NVIDIA TensorRT 8.2.5 APIs, parsers, and layers.![](https://docs.nvidia.com/favicon.ico)](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-825/support-matrix/index.html?ref=yinguobing.com)

TensorRT 8.2.5支持的CUDA版本还是比较齐全的。不过cuDNN的版本只显示了8.2.1。所以需要根据你的实际需求确定CUDA版本。由于我计划使用ONNXRUNTIME，同样查询官方给出的支持矩阵：

[TensorRTInstructions to execute ONNX Runtime on NVIDIA GPUs with the TensorRT execution provider![](https://onnxruntime.ai/favicon.ico)onnxruntime](https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html?ref=yinguobing.com)

| ONNX Runtime | TensorRT | CUDA |
| ------------ | -------- | ---- |
| master       | 8.2      | 11.4 |
| 1.11         | 8.2      | 11.4 |

这里显示1.11版本支持的CDUA为11.4。

### 下载安装包

从官网下载安装包。注意这里可能需要以开发者账户登录。

[NVIDIA TensorRTNVIDIA TensorRT What is NVIDIA TensorRT Features Key Products Performance Framework Integrations Success Stories Introductory Resources NVIDIA TensorRT NVIDIA® TensorRT™, an SDK for high-performance deep learning inference, includes a deep learning inference optimizer and runtime that delivers low l…![](https://developer.nvidia.com/sites/all/themes/devzone_new/favicon.ico)NVIDIA Developer![](https://www.nvidia.com/content/dam/en-zz/Solutions/homepage/Datacenter-AI_Accelerated-407@2x.jpg)](https://developer.nvidia.com/tensorrt?ref=yinguobing.com)

### 安装

首先解压安装包：

```bash
tar xzvf TensorRT-8.2.5.1.Linux.x86_64-gnu.cuda-11.4.cudnn8.2.tar.gz
```

然后将安装包拷贝到你计划使用的位置：

```bash
sudo mv TensorRT-8.2.5.1 /usr/local/
```

完成。

### 使用

设定动态链接库的环境变量：

```bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/TensorRT-8.2.5.1/lib
```

你也可以将这行指令加入到 `home` 目录下的 `.bashrc` 中。