TensorRT broken package unmatch version in docker build

Dockerfile

FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04

...

ARG TRT_VERSION=8.4.3.1-1+cuda11.6
RUN python3 -m pip install -U \
		numpy

RUN apt-get update && \
	apt-get install -y --no-install-recommends \
		tensorrt-dev=${TRT_VERSION} \
		python3-libnvinfer \
	&& rm -rf /var/lib/apt/lists/* \
    && apt-get clean \
	&& apt-mark hold tensorrt-dev libcudnn8 libcudnn8-dev

Error message

The following packages have unmet dependencies:
 tensorrt-dev : Depends: libnvinfer-dev (= 8.4.3-1+cuda11.6) but 8.5.1-1+cuda11.8 is to be installed
                Depends: libnvinfer-plugin-dev (= 8.4.3-1+cuda11.6) but 8.5.1-1+cuda11.8 is to be installed
                Depends: libnvparsers-dev (= 8.4.3-1+cuda11.6) but 8.5.1-1+cuda11.8 is to be installed
                Depends: libnvonnxparsers-dev (= 8.4.3-1+cuda11.6) but 8.5.1-1+cuda11.8 is to be installed
E: Unable to correct problems, you have held broken packages.

I have followed the guide from nvidia about using deb(network) to install TensorRT inside the nvidia cuda&cudnn container. It mentioned that if using this container, the step 1 add key can be skipped.

I am wondering why I have already specific the version I would like to install, it still trying to get the latest to be installed? Actually this dockerfile is worked just few days ago, and it fail because of this in yesterday.

Solution

Please refer to this link. The reason why causing error is because the base image always refer to the latest version packages. To specify versioning, you have to apt-get install the exact deb packages. Below updated dockerfile is the reference.

This Dockerfile gives the hints as well.

Updated Dockerfile

FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04

ARG TRT_VERSION=8.4.3-1+cuda11.6

RUN apt-get update && \
	apt-get install -y --no-install-recommends \
		libnvinfer8=${TRT_VERSION} libnvonnxparsers8=${TRT_VERSION} libnvparsers8=${TRT_VERSION} libnvinfer-plugin8=${TRT_VERSION} \
        libnvinfer-dev=${TRT_VERSION} libnvonnxparsers-dev=${TRT_VERSION} libnvparsers-dev=${TRT_VERSION} libnvinfer-plugin-dev=${TRT_VERSION} \
	&& rm -rf /var/lib/apt/lists/* \
	&& apt-get clean \
	&& apt-mark hold libcudnn8 libcudnn8-dev libnvinfer8 libnvonnxparsers8 libnvparsers8 libnvinfer-plugin8 libnvinfer-dev libnvonnxparsers-dev libnvparsers-dev libnvinfer-plugin-dev

Question

From the above link Dockerfile from Nvidia

ENV TRT_LIBPATH /usr/lib/x86_64-linux-gnu
ENV TRT_OSSPATH /workspace/TensorRT
ENV PATH="${PATH}:/usr/local/bin/ngc-cli"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${TRT_OSSPATH}/build/out:${TRT_LIBPATH}"

Some ENV were set, I haven’t done this in my own image, would this causing any path error or something else later on? As I am working on ROS2 environment, and dont want to set some environment variable that I dont really know it purpose.

I am also using a root user to install these TensorRT packages, however for ROS2, I am using a UID/GID=1000 user named as ros.

I hope someone could explain this question, great thanks!