-Modified Dockerfile.base to cudagl
-Changed demo to take in input from demoConfig.yaml file -Readme changes for demo.md
This commit is contained in:
@@ -21,3 +21,4 @@ scripts/COCO_val2017/*
|
||||
scripts/COCO_val2017.zip
|
||||
scripts/all_labels.txt
|
||||
/cmake/cuda_script
|
||||
/cmake-build-debug/
|
||||
|
||||
+55
-57
@@ -18,64 +18,57 @@ void sig_handler(int signo) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
std::cout<<"detection\n";
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
#ifdef __linux__
|
||||
std::string config_file = "../demo/demoConfig.yaml";
|
||||
#elif _WIN32
|
||||
std::string config_file = "..\\..\\..\\demo\\demoConfig.yaml";
|
||||
#endif
|
||||
|
||||
std::string net = "yolo4tiny_fp32.rt";
|
||||
#ifdef __linux__
|
||||
std::string cfgPath = "../tests/darknet/cfg/yolo4tiny.cfg";
|
||||
#elif _WIN32
|
||||
std::string cfgPath = "..\\tests\\darknet\\cfg\\yolo4tiny.cfg";
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
std::string namePath = "../tests/darknet/names/coco.names";
|
||||
#elif _WIN32
|
||||
std::string namePath = "..\\tests\\darknet\\names\\coco.names";
|
||||
#endif
|
||||
|
||||
if(argc > 1)
|
||||
net = argv[1];
|
||||
#ifdef __linux__
|
||||
std::string input = "../demo/yolo_test.mp4";
|
||||
#elif _WIN32
|
||||
std::string input = "..\\demo\\yolo_test.mp4";
|
||||
#endif
|
||||
|
||||
char ntype = 'y';
|
||||
if(argc > 2)
|
||||
input = argv[2];
|
||||
if(argc > 3)
|
||||
ntype = argv[3][0];
|
||||
int n_classes = 80;
|
||||
if(argc > 4)
|
||||
n_classes = atoi(argv[4]);
|
||||
if(argc > 5)
|
||||
cfgPath = argv[5];
|
||||
if(argc > 6)
|
||||
namePath = argv[6];
|
||||
int n_batch = 1;
|
||||
if(argc > 7)
|
||||
n_batch = atoi(argv[7]);
|
||||
bool show = true;
|
||||
if(argc > 8)
|
||||
show = atoi(argv[8]);
|
||||
float conf_thresh=0.3;
|
||||
if(argc >= 9)
|
||||
conf_thresh = atof(argv[9]);
|
||||
|
||||
if(n_batch < 1 || n_batch > 64)
|
||||
FatalError("Batch dim not supported");
|
||||
|
||||
if(!show)
|
||||
SAVE_RESULT = true;
|
||||
|
||||
if(ntype == 'c' || ntype == 'm'){
|
||||
cfgPath = "";
|
||||
namePath = "";
|
||||
|
||||
if(argc > 1){
|
||||
config_file = argv[1];
|
||||
}
|
||||
|
||||
YAML::Node conf = YAMLloadConf(config_file);
|
||||
if(!conf){
|
||||
FatalError("Problem with config file");
|
||||
}
|
||||
|
||||
|
||||
std::string net = YAMLgetConf<std::string>(conf,"net","yolo4tiny_fp32.rt");
|
||||
if(!fileExist(net.c_str())) {
|
||||
FatalError("The given network does not exist. Create the rt first.");
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
std::string input = YAMLgetConf<std::string>(conf, "input", "../demo/yolo_test.mp4");
|
||||
std::string cfgPath = YAMLgetConf<std::string>(conf,"cfg_input", "../tests/darknet/cfg/yolo4tiny.cfg");
|
||||
std::string namePath = YAMLgetConf<std::string>(conf,"name_input","../tests/darknet/names/coco.names");
|
||||
#elif _WIN32
|
||||
std::string input = YAMLgetConf(conf, "win_input", "..\\..\\..\\demo\\yolo_test.mp4");
|
||||
std::string cfgPath = YAMLgetConf(conf,"cfg_win_input","..\\..\\..\\tests\\darknet\\cfg\\yolo4tiny.cfg");
|
||||
std::string namePath = YAMLgetConf(conf,"name_win_input","..\\..\\..\\tests\\darknet\\names\\coco.names");
|
||||
#endif
|
||||
if(!fileExist(input.c_str()))
|
||||
FatalError("The given input video does not exist.");
|
||||
|
||||
char ntype = YAMLgetConf<char>(conf, "ntype", 'y');
|
||||
int n_classes = YAMLgetConf<int>(conf, "n_classes", 80);
|
||||
int n_batch = YAMLgetConf<int>(conf, "n_batch", 1);
|
||||
if(n_batch < 1 || n_batch > 64)
|
||||
FatalError("Batch dim not supported");
|
||||
float conf_thresh = YAMLgetConf<float>(conf, "conf_thresh", 0.3);
|
||||
bool show = YAMLgetConf<bool>(conf, "show", true);
|
||||
bool save = YAMLgetConf<bool>(conf, "save", false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tk::dnn::Yolo3Detection yolo;
|
||||
tk::dnn::CenternetDetection cnet;
|
||||
tk::dnn::MobilenetDetection mbnet;
|
||||
@@ -98,6 +91,11 @@ int main(int argc, char *argv[]) {
|
||||
FatalError("Network type not allowed (3rd parameter)\n");
|
||||
}
|
||||
|
||||
if(ntype == 'c' || ntype == 'm'){
|
||||
cfgPath = "";
|
||||
namePath = "";
|
||||
}
|
||||
|
||||
detNN->init(net,cfgPath,namePath,n_classes,n_batch,conf_thresh);
|
||||
|
||||
gRun = true;
|
||||
@@ -109,7 +107,7 @@ int main(int argc, char *argv[]) {
|
||||
std::cout<<"camera started\n";
|
||||
|
||||
cv::VideoWriter resultVideo;
|
||||
if(SAVE_RESULT) {
|
||||
if(save) {
|
||||
int w = cap.get(cv::CAP_PROP_FRAME_WIDTH);
|
||||
int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
|
||||
resultVideo.open("result.mp4", cv::VideoWriter::fourcc('M','P','4','V'), 30, cv::Size(w, h));
|
||||
@@ -149,7 +147,7 @@ int main(int argc, char *argv[]) {
|
||||
cv::waitKey(1);
|
||||
}
|
||||
}
|
||||
if(n_batch == 1 && SAVE_RESULT)
|
||||
if(n_batch == 1 && save)
|
||||
resultVideo << frame;
|
||||
}
|
||||
|
||||
@@ -157,7 +155,7 @@ int main(int argc, char *argv[]) {
|
||||
double mean = 0;
|
||||
|
||||
std::cout<<COL_GREENB<<"\n\nTime stats:\n";
|
||||
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
||||
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
||||
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
||||
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
|
||||
std::cout<<"Avg: "<<mean/n_batch<<" ms\t"<<1000/(mean/n_batch)<<" FPS\n"<<COL_END;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# video input
|
||||
input : "../demo/yolo_test.mp4"
|
||||
win_input : "..\\..\\..\\demo\\yolo_test.mp4"
|
||||
|
||||
#cfg input
|
||||
cfg_input : "../tests/darknet/cfg/yolo4tiny.cfg"
|
||||
cfg_win_input : "..\\..\\..\\tests\\darknet\\cfg\\yolo4tiny.cfg"
|
||||
|
||||
#name input
|
||||
name_input : "../tests/darknet/names/coco.names"
|
||||
name_win_input : "..\\..\\..\\tests\\darknet\\names\\coco.names"
|
||||
|
||||
# network config
|
||||
net : "yolo4tiny_fp32.rt"
|
||||
ntype : 'y'
|
||||
n_classes : 80
|
||||
n_batch : 1
|
||||
conf_thresh : 0.3
|
||||
|
||||
# demo config
|
||||
show : true
|
||||
save : false
|
||||
+121
-38
@@ -1,57 +1,140 @@
|
||||
FROM nvidia/cuda:11.3.1-devel-ubuntu20.04
|
||||
LABEL maintainer "Francesco Gatti"
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install libcudnn8-dev=8.2.1.32-1+cuda11.3 libcudnn8=8.2.1.32-1+cuda11.3 libnvinfer-dev=8.0.3-1+cuda11.3 libnvinfer8=8.0.3-1+cuda11.3
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt install -y git wget libeigen3-dev libyaml-cpp-dev gcc-9 g++-9 libopengl-dev libgl-dev
|
||||
RUN cd /tmp && \
|
||||
wget https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-Linux-x86_64.sh && \
|
||||
chmod +x cmake-3.21.4-Linux-x86_64.sh && \
|
||||
./cmake-3.21.4-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license && \
|
||||
rm ./cmake-3.21.4-Linux-x86_64.sh
|
||||
FROM nvidia/cudagl:11.3.1-devel-ubuntu20.04
|
||||
|
||||
LABEL maintainer "TKDNN AUTHORS"
|
||||
LABEL Description="tkDNN+cudagl"
|
||||
LABEL com.tkdnn.nvidia.version="11.3.1"
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV CC gcc
|
||||
ENV CXX g++
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libblkid-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libcudnn8-dev=8.2.1.32-1+cuda11.3 \
|
||||
libcudnn8=8.2.1.32-1+cuda11.3 \
|
||||
libnvinfer-dev=8.0.3-1+cuda11.3 \
|
||||
libnvinfer8=8.0.3-1+cuda11.3 && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libblkid-dev \
|
||||
locales \
|
||||
lsb-release \
|
||||
mesa-utils \
|
||||
git \
|
||||
nano \
|
||||
terminator \
|
||||
wget \
|
||||
curl \
|
||||
libssl-dev \
|
||||
htop \
|
||||
dbus-x11 \
|
||||
libqt5opengl5-dev \
|
||||
libgtk-3-dev \
|
||||
libvtk7-dev \
|
||||
libv4l-dev \
|
||||
tar \
|
||||
libgoogle-glog-dev \
|
||||
libgflags-dev \
|
||||
gfortran-9 \
|
||||
libtbb-dev \
|
||||
libgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
libdc1394-22-dev \
|
||||
libavresample-dev \
|
||||
libatlas-cpp-0.6-dev \
|
||||
python3-dev \
|
||||
gdb \
|
||||
python3-pip \
|
||||
unzip libtbb-dev && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
software-properties-common && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-add-repository universe
|
||||
RUN apt-get update && apt-get install -y python3-pip python3 openssh-server ssh pyqt5-dev sip-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
RUN pip3 install --upgrade pip
|
||||
RUN pip3 install --upgrade virtualenv
|
||||
RUN pip3 install --upgrade paramiko
|
||||
RUN pip3 install --ignore-installed --upgrade numpy protobuf
|
||||
|
||||
|
||||
RUN cd ~ && mkdir build
|
||||
RUN cd ~/build && wget https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4.tar.gz && \
|
||||
tar -xvf cmake-3.21.4.tar.gz && cd cmake-3.21.4 && ./configure --prefix=/usr/local --qt-gui --parallel=12 && \
|
||||
make -j8 && make install
|
||||
|
||||
RUN apt-get update && apt-get install -y automake autoconf pkg-config libevent-dev libncurses5-dev bison && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/
|
||||
|
||||
RUN git clone https://github.com/tmux/tmux.git && \
|
||||
cd tmux && git checkout tags/3.2 && ls -la && sh autogen.sh && ./configure && make -j8 && make install
|
||||
|
||||
RUN apt-get update && apt-get install -y zsh && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
|
||||
RUN chsh -s /usr/bin/zsh root
|
||||
RUN git clone https://github.com/sindresorhus/pure /root/.oh-my-zsh/custom/pure
|
||||
RUN ln -s /root/.oh-my-zsh/custom/pure/pure.zsh-theme /root/.oh-my-zsh/custom/
|
||||
RUN ln -s /root/.oh-my-zsh/custom/pure/async.zsh /root/.oh-my-zsh/custom/
|
||||
RUN sed -i -e 's/robbyrussell/refined/g' /root/.zshrc
|
||||
RUN sed -i '/plugins=(/c\plugins=(git git-flow adb pyenv tmux)' /root/.zshrc
|
||||
|
||||
RUN mkdir -p /root/.config/terminator/
|
||||
COPY assets/terminator_config /root/.config/terminator/config
|
||||
|
||||
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
|
||||
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf && \
|
||||
echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/nvidia.conf
|
||||
|
||||
|
||||
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
|
||||
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/lib:/usr/lib/x86_64-linux-gnu:/usr/local/lib:${LD_LIBRARY_PATH}
|
||||
ENV NVIDIA_VISIBLE_DEVICES all
|
||||
RUN echo "INSTALL OPENCV"
|
||||
RUN apt-get install -y build-essential \
|
||||
unzip \
|
||||
pkg-config \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libtiff-dev \
|
||||
libavcodec-dev \
|
||||
libavformat-dev \
|
||||
libswscale-dev \
|
||||
libv4l-dev \
|
||||
libxvidcore-dev \
|
||||
libx264-dev \
|
||||
libgtk-3-dev \
|
||||
libatlas-base-dev \
|
||||
gfortran-9 \
|
||||
libtbb-dev \
|
||||
libgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
libdc1394-22-dev \
|
||||
libavresample-dev
|
||||
RUN cd && wget https://github.com/opencv/opencv/archive/4.5.4.tar.gz && tar -xf 4.5.4.tar.gz && rm *.tar.gz
|
||||
RUN cd && wget https://github.com/opencv/opencv_contrib/archive/4.5.4.tar.gz && tar -xf 4.5.4.tar.gz && rm *.tar.gz
|
||||
RUN cd && \
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,graphics
|
||||
|
||||
|
||||
|
||||
RUN cd ~/build && wget https://github.com/opencv/opencv/archive/4.5.4.tar.gz && tar -xf 4.5.4.tar.gz && rm 4.5.4.tar.gz
|
||||
RUN cd ~/build && wget https://github.com/opencv/opencv_contrib/archive/4.5.4.tar.gz && tar -xf 4.5.4.tar.gz && rm 4.5.4.tar.gz
|
||||
RUN cd ~/build && \
|
||||
cd opencv-4.5.4 && mkdir build && cd build && \
|
||||
cmake -D CMAKE_BUILD_TYPE=RELEASE \
|
||||
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
||||
-D INSTALL_PYTHON_EXAMPLES=OFF \
|
||||
-D INSTALL_C_EXAMPLES=OFF \
|
||||
-D OPENCV_EXTRA_MODULES_PATH='~/opencv_contrib-4.5.4/modules' \
|
||||
-D OPENCV_EXTRA_MODULES_PATH='~/build/opencv_contrib-4.5.4/modules' \
|
||||
-D BUILD_EXAMPLES=OFF \
|
||||
-D BUILD_TESTS=OFF \
|
||||
-D BUILD_PERF_TESTS=OFF \
|
||||
-D BUILD_DOCS=OFF \
|
||||
-D WITH_CUDA=ON \
|
||||
-D WITH_OPENGL=ON \
|
||||
-D WITH_NVCUVID=ON \
|
||||
-D CUDA_ARCH_BIN=7.2 \
|
||||
-D CUDA_ARCH_PTX="" \
|
||||
-D CUDA_ARCH_PTX=7.2 \
|
||||
-D ENABLE_FAST_MATH=ON \
|
||||
-D CUDA_FAST_MATH=ON \
|
||||
-D WITH_CUBLAS=ON \
|
||||
-D WITH_CUDNN=ON \
|
||||
-D WITH_OPENMP=ON \
|
||||
-D WITH_NONFREE=ON \
|
||||
-D WITH_LIBV4L=ON \
|
||||
-D WITH_GSTREAMER=ON \
|
||||
-D WITH_GSTREAMER_0_10=OFF \
|
||||
-D WITH_TBB=ON \
|
||||
../ && make -j12 && make install
|
||||
RUN apt clean
|
||||
../ && make -j12 && make install && ldconfig
|
||||
|
||||
RUN cd ~ && rm -rf build
|
||||
|
||||
RUN cd ~ && mkdir Development && cd Development && \
|
||||
git clone https://github.com/ceccocats/tkDNN.git && cd tkDNN && \
|
||||
mkdir build && cd build && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .. && \
|
||||
make -j6
|
||||
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
COPY assets/entrypoint_setup.sh /
|
||||
ENTRYPOINT ["/entrypoint_setup.sh"]
|
||||
CMD ["terminator"]
|
||||
+1
-4
@@ -9,13 +9,10 @@ docker build -t tkdnn:build -f Dockerfile .
|
||||
# make nvidia docker working
|
||||
# follow this guide: https://github.com/NVIDIA/nvidia-docker
|
||||
|
||||
# dowload tensorrt
|
||||
# from: https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.0/7.0.0.11/local_repo/nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb
|
||||
|
||||
# build image
|
||||
docker build -t ceccocats/tkdnn:latest -f Dockerfile.base .
|
||||
|
||||
# run image
|
||||
docker run -ti --gpus all --rm ceccocats/tkdnn:latest bash
|
||||
./docker_launch.sh
|
||||
```
|
||||
|
||||
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#! /bin/bash
|
||||
|
||||
CMD=
|
||||
|
||||
# Functions
|
||||
# TOOD: Check if we can use: getent passwd $USER to extract all variables
|
||||
# TODO: Check for valid inputs, cause now it will go through even with bad inputs
|
||||
check_envs () {
|
||||
DOCKER_CUSTOM_USER_OK=true;
|
||||
if [ -z ${DOCKER_USER_NAME+x} ]; then
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
fi
|
||||
|
||||
if [ -z ${DOCKER_USER_ID+x} ]; then
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
else
|
||||
if ! [ -z "${DOCKER_USER_ID##[0-9]*}" ]; then
|
||||
echo -e "\033[1;33mWarning: User-ID should be a number. Falling back to defaults.\033[0m"
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z ${DOCKER_USER_GROUP_NAME+x} ]; then
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
fi
|
||||
|
||||
if [ -z ${DOCKER_USER_GROUP_ID+x} ]; then
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
else
|
||||
if ! [ -z "${DOCKER_USER_GROUP_ID##[0-9]*}" ]; then
|
||||
echo -e "\033[1;33mWarning: Group-ID should be a number. Falling back to defaults.\033[0m"
|
||||
DOCKER_CUSTOM_USER_OK=false;
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setup_env_user () {
|
||||
USER=$1
|
||||
USER_ID=$2
|
||||
GROUP=$3
|
||||
GROUP_ID=$4
|
||||
|
||||
## Create user
|
||||
useradd -m $USER
|
||||
|
||||
## Copy zsh/sh configs
|
||||
cp /root/.profile /home/$USER/
|
||||
cp /root/.bashrc /home/$USER/
|
||||
cp /root/.zshrc /home/$USER/
|
||||
## Copy terminator configs
|
||||
mkdir -p /home/$USER/.config/terminator
|
||||
cp /root/.config/terminator/config /home/$USER/.config/terminator/config
|
||||
cp /root/.config/terminator/background.png /home/$USER/.config/terminator/background.png
|
||||
cp -rf /root/.oh-my-zsh /home/$USER/
|
||||
cp -rf /root/tkDNN /home/$USER/
|
||||
rm -rf /home/$USER/.oh-my-zsh/custom/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/async.zsh
|
||||
ln -s /home/$USER/.oh-my-zsh/custom/pure/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/
|
||||
ln -s /home/$USER/.oh-my-zsh/custom/pure/async.zsh /home/$USER/.oh-my-zsh/custom/
|
||||
sed -i -e 's@ZSH=\"/root@ZSH=\"/home/$USER@g' /home/$USER/.zshrc
|
||||
# Copy SSH keys & fix owner
|
||||
if [ -d "/root/.ssh" ]; then
|
||||
cp -rf /root/.ssh /home/$USER/
|
||||
chown -R $USER:$GROUP /home/$USER/.ssh
|
||||
fi
|
||||
|
||||
## Fix owner
|
||||
chown $USER:$GROUP /home/$USER
|
||||
chown -R $USER:$GROUP /home/$USER/.config
|
||||
chown $USER:$GROUP /home/$USER/.profile
|
||||
chown $USER:$GROUP /home/$USER/.bashrc
|
||||
chown $USER:$GROUP /home/$USER/.zshrc
|
||||
chown -R $USER:$GROUP /home/$USER/.oh-my-zsh
|
||||
chown -R $USER:$GROUP /home/$USER/tkDNN
|
||||
|
||||
## This a trick to keep the evnironmental variables of root which is important!
|
||||
echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.bashrc
|
||||
echo " cd /home/$DOCKER_USER_NAME" >> /root/.bashrc
|
||||
echo " su $DOCKER_USER_NAME" >> /root/.bashrc
|
||||
echo "fi" >> /root/.bashrc
|
||||
|
||||
echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.zshrc
|
||||
echo " cd /home/$DOCKER_USER_NAME" >> /root/.zshrc
|
||||
echo " su $DOCKER_USER_NAME" >> /root/.zshrc
|
||||
echo "fi" >> /root/.zshrc
|
||||
|
||||
## Setup Password-file
|
||||
PASSWDCONTENTS=$(grep -v "^${USER}:" /etc/passwd)
|
||||
GROUPCONTENTS=$(grep -v -e "^${GROUP}:" -e "^docker:" /etc/group)
|
||||
|
||||
(echo "${PASSWDCONTENTS}" && echo "${USER}:x:$USER_ID:$GROUP_ID::/home/$USER:/bin/bash") > /etc/passwd
|
||||
(echo "${GROUPCONTENTS}" && echo "${GROUP}:x:${GROUP_ID}:") > /etc/group
|
||||
(if test -f /etc/sudoers ; then echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ; fi)
|
||||
}
|
||||
|
||||
|
||||
# ---Main---
|
||||
|
||||
# Create new user
|
||||
## Check Inputs
|
||||
check_envs
|
||||
|
||||
## Determine user & Setup Environment
|
||||
if [ $DOCKER_CUSTOM_USER_OK == true ]; then
|
||||
echo " -->DOCKER_USER Input is set to '$DOCKER_USER_NAME:$DOCKER_USER_ID:$DOCKER_USER_GROUP_NAME:$DOCKER_USER_GROUP_ID'";
|
||||
echo -e "\033[0;32mSetting up environment for user=$DOCKER_USER_NAME\033[0m"
|
||||
setup_env_user $DOCKER_USER_NAME $DOCKER_USER_ID $DOCKER_USER_GROUP_NAME $DOCKER_USER_GROUP_ID
|
||||
else
|
||||
echo " -->DOCKER_USER* variables not set. Using 'root'.";
|
||||
echo -e "\033[0;32mSetting up environment for user=root\033[0m"
|
||||
DOCKER_USER_NAME="root"
|
||||
fi
|
||||
|
||||
# Change shell to zsh
|
||||
chsh -s /usr/bin/zsh $DOCKER_USER_NAME
|
||||
|
||||
# Run CMD from Docker
|
||||
"$@"
|
||||
@@ -0,0 +1,18 @@
|
||||
[global_config]
|
||||
title_transmit_bg_color = "#2e3436"
|
||||
[keybindings]
|
||||
[layouts]
|
||||
[[default]]
|
||||
[[[child1]]]
|
||||
parent = window0
|
||||
type = Terminal
|
||||
[[[window0]]]
|
||||
parent = ""
|
||||
type = Window
|
||||
[plugins]
|
||||
[profiles]
|
||||
[[default]]
|
||||
background_color = "#282828"
|
||||
cursor_color = "#aaaaaa"
|
||||
foreground_color = "#f3f3f3"
|
||||
palette = "#000000:#aa0000:#00aa00:#c4a000:#3465a4:#75507b:#06989a:#d3d7cf:#88807c:#f15d22:#73c48f:#ffce51:#48b9c7:#ad7fa8:#34e2e2:#eeeeec"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
xhost local:root
|
||||
docker run --rm -it --runtime=nvidia --privileged --net=host --cap-add sys_ptrace -d --ipc=host \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY \
|
||||
-v $HOME/.Xauthority:/home/$(id -un)/.Xauthority -e XAUTHORITY=/home/$(id -un)/.Xauthority \
|
||||
-e DOCKER_USER_NAME=$(id -un) \
|
||||
-e DOCKER_USER_ID=$(id -u) \
|
||||
-e DOCKER_USER_GROUP_NAME=$(id -gn) \
|
||||
-e DOCKER_USER_GROUP_ID=$(id -g) \
|
||||
-v $HOME/.ssh:/home/$(id -un)/.ssh ceccocats/tkdnn
|
||||
+19
-24
@@ -30,31 +30,24 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug -DDEBUG=True
|
||||
make
|
||||
```
|
||||
|
||||
Once you have successfully created your rt file, run the demo(yolo) :
|
||||
Once you have successfully created your rt file, run the demo:
|
||||
```
|
||||
./demo yolo4_fp32.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||
./ demo <path-to-config>
|
||||
```
|
||||
In general the demo program takes 1 parameter, the ```<path-to-config>``` that is the path to che configuration file. The parameter is optional and its default value is ```"../demo/demoConfig.yaml"```.
|
||||
|
||||
To run demo for mobilenet and centernet for the created rt file :
|
||||
```
|
||||
./demo mobilenetv2ssd_fp32.rt m 20
|
||||
```
|
||||
|
||||
In general the demo program takes 7 parameters:
|
||||
```
|
||||
./demo <network-rt-file> <path-to-video> <kind-of-network> <number-of-classes> <cfg-path> <name-path> <n-batches> <show-flag> <conf-thresh>
|
||||
```
|
||||
where
|
||||
|
||||
* ```<network-rt-file>``` is the rt file generated by a test
|
||||
* ```<<path-to-video>``` is the path to a video file or a camera input
|
||||
* ```<kind-of-network>``` is the type of network. Thee types are currently supported: ```y``` (YOLO family), ```c``` (CenterNet family) and ```m``` (MobileNet-SSD family)
|
||||
* ```<number-of-classes>```is the number of classes the network is trained on
|
||||
* ```<cfg-path> ```is the relative path to the config file (only for darknet based networks) used to train the network
|
||||
* ```<name-path>```is the relative path to the names file (only for darknet based networks) used to train the network
|
||||
* ```<n-batches>``` number of batches to use in inference (N.B. you should first export TKDNN_BATCHSIZE to the required n_batches and create again the rt file for the network).
|
||||
* ```<show-flag>``` if set to 0 the demo will not show the visualization but save the video into result.mp4 (if n-batches ==1)
|
||||
* ```<conf-thresh>``` confidence threshold for the detector. Only bounding boxes with threshold greater than conf-thresh will be displayed.
|
||||
The config file is a yaml file with the following attributes:
|
||||
* ```net``` is the rt file generated by a test
|
||||
* ```input``` is the path to a video file or a camera input (on Linux)
|
||||
* ```win_input``` is the path to a video file or a camera input (on Windows)
|
||||
* ```ntype``` is the type of network. Thee types are currently supported: ```y``` (YOLO family), ```c``` (CenterNet family) and ```m``` (MobileNet-SSD family)
|
||||
* ```n_classes``` is the number of classes the network is trained on
|
||||
* ```n_batch``` number of batches to use in inference (N.B. you should first export TKDNN_BATCHSIZE to the required n_batches and create again the rt file for the network).
|
||||
* ```conf_thresh``` confidence threshold for the detector. Only bounding boxes with threshold greater than conf-thresh will be displayed.
|
||||
* ```show``` if set to 0 the demo will not show the visualization (if n-batches ==1)
|
||||
* ```save``` if set to 1 the demo will save the video of the demo into result.mp4 (if n-batches ==1)
|
||||
* ```cfg_input``` (for linux) \ ```cfg_win_input``` (for windows) is the location of the cfg path of the network for mobilenet and centernet networks use ```" "```
|
||||
* ```name_input``` (for linux) \ ```name_win_input``` (for windows) is the location of the name path of the network for mobilenet and centernet networks use ```" "```
|
||||
|
||||
N.B. By default it is used FP32 inference
|
||||
|
||||
@@ -69,7 +62,8 @@ To run the demo with FP16 inference follow these steps (example with yolov3):
|
||||
export TKDNN_MODE=FP16 # set the half floating point optimization
|
||||
rm yolo4_fp16.rt # be sure to delete(or move) old tensorRT files
|
||||
./test_yolo4 # run the yolo test (is slow)
|
||||
./demo yolo4_fp16.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||
#set net: yolo4_fp16.rt in the config file
|
||||
./demo
|
||||
```
|
||||
N.B. Using FP16 inference will lead to some errors in the results (first or second decimal).
|
||||
|
||||
@@ -94,7 +88,8 @@ export TKDNN_CALIB_LABEL_PATH=../demo/COCO_val2017/all_labels.txt
|
||||
export TKDNN_CALIB_IMG_PATH=../demo/COCO_val2017/all_images.txt
|
||||
rm yolo4_int8.rt # be sure to delete(or move) old tensorRT files
|
||||
./test_yolo4 # run the yolo test (is slow)
|
||||
./demo yolo4_int8.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||
#set net: yolo4_int8.rt in the config file
|
||||
./demo
|
||||
```
|
||||
N.B.
|
||||
|
||||
|
||||
+16
-1
@@ -6,6 +6,8 @@
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
|
||||
#include "cuda.h"
|
||||
#include "cuda_runtime_api.h"
|
||||
@@ -16,7 +18,6 @@
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <ios>
|
||||
@@ -161,5 +162,19 @@ static inline bool isCudaPointer(void *data) {
|
||||
return cudaPointerGetAttributes(&attr, data) == 0;
|
||||
}
|
||||
|
||||
inline YAML::Node YAMLloadConf(const std::string& conf_file) {
|
||||
std::cerr<<"Loading YAML: "<<conf_file<<"\n";
|
||||
return YAML::LoadFile(conf_file);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T YAMLgetConf(YAML::Node conf, std::string key, T defaultVal) {
|
||||
T val = defaultVal;
|
||||
if(conf && conf[key]) {
|
||||
val = conf[key].as<T>();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
#endif //UTILS_H
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import sys
|
||||
import pandas as pd
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print("Error: two csv files are needed, old first new second")
|
||||
exit(1)
|
||||
|
||||
old_perf_file = str(sys.argv[1])
|
||||
new_perf_file = str(sys.argv[2])
|
||||
|
||||
verbose = False
|
||||
if len(sys.argv) == 4:
|
||||
verbose = bool(sys.argv[3])
|
||||
|
||||
print("Comparing {} vs {}".format(old_perf_file, new_perf_file))
|
||||
|
||||
df_old = pd.read_csv (old_perf_file, sep=';', header=None, index_col=0)
|
||||
df_new = pd.read_csv (new_perf_file, sep=';', header=None, index_col=0)
|
||||
|
||||
for index, row in df_new.iterrows():
|
||||
if index in df_old.index:
|
||||
if verbose:
|
||||
print("New: ",row[1], row[2], row[3])
|
||||
print("Old: ",df_old.loc[index][1], df_old.loc[index][2], df_old.loc[index][3])
|
||||
|
||||
print(index, end=': ')
|
||||
if abs(row[1] - df_old.loc[index][1]) < df_old.loc[index][1]*0.1:
|
||||
print("similar performance")
|
||||
elif (row[1] < df_old.loc[index][1]):
|
||||
print('\x1b[3;30;42m' + 'faster' + '\x1b[0m')
|
||||
elif (row[1] > df_old.loc[index][1]):
|
||||
if row[1] > df_old.loc[index][1] + df_old.loc[index][1] * 0.5 :
|
||||
print('\x1b[3;30;41m' + 'WAY SLOWER' + '\x1b[0m')
|
||||
else:
|
||||
print('\x1b[3;30;41m' + 'slower' + '\x1b[0m')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user