首先安装docker
sudo apt-get install docker
拉取一个镜像,包含nvidia,cuda cudnn基本环境
sudo docker pull nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04
若docker pull 有点慢可以加速一下
操作如下:
sudo vim /etc/docker/daemon.json
添加如下:
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
重新启动docker
sudo service docker restart
启动容器,进入镜像
docker run -it --gpus all -v 本地路径:镜像路径(挂载)id /bin/bash
去nvidai 官网下载tensorrt
https://developer.nvidia.com/zh-cn/tensorrt
点击立即下载
点击TensorRT8
点击TensorRT8.2GA Update 4
选择第一个TAR那个包下载
TensorRT 8.2 GA Update 4 for Linux x86_64 and CUDA 11.0, 11.1, 11.2, 11.3, 11.4 and 11.5 TAR Package
进入docker
sudo docker run -it nvidia/cuda:11.4-cudnd8-devel-ubuntu18.04 /bin/bash
对docker环境进行配置安装依赖
apt-get update
apt-get install vim
apt-get install zip
安装python3环境
apt-get install python3
apt-get install python3-pip
apt-get install python3-dev
apt-get install python3-wheel
cd /usr/local/bin
ln -s /usr/bin/python3 python
ln -s /usr/bin/pip3 pip
对pip3进行切换国内源
python3 -m pip install -i https://pypi.douban.com/simple/ --upgrade pip
pip3 config set global.index-url https://pypi.douban.com/simple/
pip3 install setuptools>=41.0.0
解压下载好的tensorrt包
tar -zxvf TensorRT-8.2.5.1.Linux.x86_64-gnu.cuda-11.4.cudnn8.2.tar.gz
设置环境变量
export LD_LIBRARY_PATH=/home/TenosrRT-8.2.5.1/lib:$LD_LIBRARY_PATH
vim ~/.bashrc
export LD_LIBRARY_PATH=/home/TenosrRT-8.2.5.1/lib:$LD_LIBRARY_PATH
source ~/.bashrc
安装tensorrt
cd TensorRT-8.2.5.1
cd python
安装对应的python型号的包
pip3 install tensorrt-8.2.5.1-cp36-none-linux_x86_64.whl
cd uff
pip3 install install uff-0.6.9-py2.py3-none-any.whl
cd onnx_graphsurgeon
pip3 install onnx_graphsurgeon-0.3.12-py2.py3-none-any.whl
验证tensorrt接口