Files
TensorRT/Dockerfile_origin
2023-12-10 01:35:25 +08:00

79 lines
2.7 KiB
Plaintext
Executable File

# For more detail, check NGC
FROM nvcr.io/nvidia/tensorrt:22.12-py3
ENV TZ=Asia/Shanghai
ARG user=jiayu
# Set timezone in case of interation during installation
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# install packages for opencv
RUN apt-get update
RUN apt install -y --no-install-recommends \
build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev \
libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev \
python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev \
build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev \
libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev \
libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev \
python3-numpy libtbb2 libtbb-dev libdc1394-22-dev
RUN apt-get -y clean && rm -rf /var/lib/apt/lists/*
#Build opencv4.5.5
RUN mkdir /root/opencv_build
WORKDIR /root/opencv_build/
RUN git clone https://github.com/opencv/opencv.git && git clone https://github.com/opencv/opencv_contrib.git && \
cd /root/opencv_build/opencv && git checkout 4.5.5 && \
cd /root/opencv_build/opencv_contrib && git checkout 4.5.5 && \
cd /root/opencv_build/opencv && mkdir build
WORKDIR /root/opencv_build/opencv/build
RUN cmake -D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D WITH_GSTREAMER=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python2=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D PYTHON3_PACKAGES_PATH=/usr/lib/python3/dist-packages \
-D CMAKE_INSTALL_PREFIX=/usr/local ..
RUN make -j16 && make install
WORKDIR /root
RUN rm -rf opencv_build
# install packages that are used for trt inferences
RUN apt-get update && apt install -y --no-install-recommends \
sudo libgflags-dev libboost-dev libxml2-dev \
libyaml-cpp-dev sqlite3 libsqlite3-dev libboost-all-dev \
lsb-release openssh-server curl gdb bash-completion
RUN apt-get -y clean && rm -rf /var/lib/apt/lists/*
# install netron to show model structure
RUN pip install netron
# set userinfo
RUN useradd -rm -c ${user} -u 1000 -d /home/${user} -s /bin/bash -G sudo ${user}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN echo '${user}:nvidia' | chpasswd
RUN apt-get update
# set working directory of trt webinar
RUN mkdir -p /home/${user}/workspace/
RUN chown -R ${user}:users /home/${user}
COPY .bashrc /home/jiayu/.bashrc
# ssh setting
RUN systemctl enable ssh
# set default working directory and user
WORKDIR /home/${user}
USER ${user}