tensorrt安装c++教程ubuntu20.0
时间: 2025-01-09 22:53:26 浏览: 37
### TensorRT C++ Installation Guide for Ubuntu 20.04
For installing TensorRT on an Ubuntu 20.04 system to use with C++, the process involves several key steps, including setting up dependencies and configuring environment variables.
Ensure that the NVIDIA driver is installed as it is a prerequisite for TensorRT[^1]. Verify this by running `nvidia-smi` from the terminal; successful execution indicates proper installation of the GPU drivers.
Next, install CUDA Toolkit which TensorRT depends upon heavily. The recommended version can be found within the compatibility matrix provided by NVIDIA documentation[^2].
After ensuring both prerequisites are met, proceed to download TensorRT directly from the NVIDIA developer website or through Docker images offered officially by NVIDIA. For direct downloads, choose the appropriate package based on your operating system and existing software stack versions like CUDA and cuDNN[^3].
Once downloaded, follow these instructions:
Install the deb file using dpkg command:
```bash
sudo dpkg -i tensorrt.deb
```
Set up necessary symbolic links if required according to specific application needs. This step might involve creating symlinks between different directories where libraries reside so applications know exactly where they need to look when linking against TensorRT during compilation time[^4].
Configure Environment Variables properly after installation completes successfully. Add paths related to include files (`/usr/include/x86_64-linux-gnu`) and library locations (`/usr/lib/x86_64-linux-gnu`) into respective sections inside `.bashrc`, then source it again to apply changes immediately without logging out/in[^5]:
Add following lines at end of ~/.bashrc :
```bash
export TENSORRT_ROOT=/usr
export LD_LIBRARY_PATH=$TENSORRT_ROOT/lib:$LD_LIBRARY_PATH
export PATH=$TENSORRT_ROOT/bin:$PATH
source ~/.bashrc
```
Finally, validate the setup by compiling and executing one of the sample projects included in the TensorRT SDK distribution. These samples provide practical examples demonstrating how to integrate TensorRT APIs effectively within custom codebases written primarily in C++ language[^6].
阅读全文
相关推荐


















