From df4a7b8eb177f9fbe7952cb419e1781cdb68ee5d Mon Sep 17 00:00:00 2001 From: JY Yang Date: Tue, 28 Nov 2023 22:37:15 +0800 Subject: [PATCH] bashrc added --- .bashrc | 121 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 75 ++-------------------------- Dockerfile_origin | 76 +++++++++++++++++++++++++++++ scripts/start.sh | 1 + 4 files changed, 201 insertions(+), 72 deletions(-) create mode 100644 .bashrc create mode 100755 Dockerfile_origin create mode 100755 scripts/start.sh diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..6a9fa38 --- /dev/null +++ b/.bashrc @@ -0,0 +1,121 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +DOCKERNAME=TensorRT + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + PS1='\[\033[01;34m\][Docker]\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@$DOCKERNAME\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}[Docker] \u@$DOCKERNAME: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi diff --git a/Dockerfile b/Dockerfile index bb397fe..d91da52 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,76 +1,7 @@ # For more detail, check NGC -FROM nvcr.io/nvidia/tensorrt:22.12-py3 +FROM git.jiayudev.com:30008/docker/tensorrt:8.5.1 + +COPY .bashrc /home/jiayu/.bashrc -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 -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 apt-get update - -# set working directory of trt webinar -RUN mkdir -p /home/${user}/workspace/ -RUN chown -R ${user}:users /home/${user} - -# ssh setting -RUN systemctl enable ssh - -# set default working directory and user -WORKDIR /home/${user} -USER ${user} diff --git a/Dockerfile_origin b/Dockerfile_origin new file mode 100755 index 0000000..bb397fe --- /dev/null +++ b/Dockerfile_origin @@ -0,0 +1,76 @@ +# 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 +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 apt-get update + +# set working directory of trt webinar +RUN mkdir -p /home/${user}/workspace/ +RUN chown -R ${user}:users /home/${user} + +# ssh setting +RUN systemctl enable ssh + +# set default working directory and user +WORKDIR /home/${user} +USER ${user} + + diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..6834847 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1 @@ +docker run -it --gpus '"device=0"' -it -e DISPLAY -v /dev/bus/usb:/dev/bus/usb -v /tmp/.X11-unix:/tmp/.X11-unix --net=host git.jiayudev.com:30008/docker/tensorrt:8.5.1