- CMakeLists.txt opencv cuda contrib autodetect
- Updated Docker to cuda-11.3+cudnn-8.2.1+TensorRT-8.0.34,Ubuntu to 20.04 and OpenCV to 4.5.4 - Updated OpenCV4 to 4.5.4 in install_OpenCV4.sh - Updated README.md
This commit is contained in:
@@ -107,8 +107,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV")
|
|||||||
if(ENABLE_OPENCV_CUDA_CONTRIB)
|
if(ENABLE_OPENCV_CUDA_CONTRIB)
|
||||||
if (OpenCV_FOUND)
|
if (OpenCV_FOUND)
|
||||||
find_package(OpenCV COMPONENTS cudawarping cudaarithm)
|
find_package(OpenCV COMPONENTS cudawarping cudaarithm)
|
||||||
|
if(OpenCV_cudawarping_FOUND AND OpenCV_cudaarithm_FOUND)
|
||||||
add_compile_definitions(OPENCV_CUDACONTRIB)
|
add_compile_definitions(OPENCV_CUDACONTRIB)
|
||||||
message("OpenCV Cuda Contrib modules found")
|
message("OpenCV Cuda Contrib modules found")
|
||||||
|
else()
|
||||||
|
message("OpenCV Cuda Contrib modules not found")
|
||||||
|
set(ENABLE_OPENCV_CUDA_CONTRIB OFF)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# if(OpenCV_CUDA_VERSION)
|
# if(OpenCV_CUDA_VERSION)
|
||||||
|
|||||||
@@ -17,10 +17,9 @@ If you use tkDNN in your research, please cite the [following paper](https://iee
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### What's new (20 July 2021)
|
### What's new (November 2021)
|
||||||
- [x] Support to sematic segmentation [README](docs/README_seg.md)
|
- [x] Support to sematic segmentation on cuda 11+ [README](docs/README_seg.md)
|
||||||
- [x] Support 2D/3D Object Detection and Tracking [README](docs/README_2d3dtracking.md)
|
- [x] Support to TensorRT8
|
||||||
- [ ] Support to TensorRT8 (WIP)
|
|
||||||
|
|
||||||
## FPS Results
|
## FPS Results
|
||||||
Inference FPS of yolov4 with tkDNN, average of 1200 images with the same dimension as the input size, on
|
Inference FPS of yolov4 with tkDNN, average of 1200 images with the same dimension as the input size, on
|
||||||
@@ -75,17 +74,17 @@ Results for COCO val 2017 (5k images), on RTX 2080Ti, with conf threshold=0.001
|
|||||||
- [Workflow](#workflow)
|
- [Workflow](#workflow)
|
||||||
- [Exporting weights](#exporting-weights)
|
- [Exporting weights](#exporting-weights)
|
||||||
- [Run the demos](#run-the-demos)
|
- [Run the demos](#run-the-demos)
|
||||||
- [tkDNN on Windows 10 (experimental)](#tkdnn-on-windows-10-experimental)
|
- [tkDNN on Windows 10 or Windows 11](#tkdnn-on-windows-10-or-windows-11)
|
||||||
- [Existing tests and supported networks](#existing-tests-and-supported-networks)
|
- [Existing tests and supported networks](#existing-tests-and-supported-networks)
|
||||||
- [References](#references)
|
- [References](#references)
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
This branch works on every NVIDIA GPU that supports the following (latest tested) dependencies:
|
This branch works on every NVIDIA GPU that supports the following (latest tested) dependencies:
|
||||||
* CUDA 11.0 (or >= 10) [the segmentation only works with CUDA 10 for now]
|
* CUDA 11.3 (or >= 10.2) [the segmentation only works with CUDA 10 for now]
|
||||||
* cuDNN 8.0.4 (or >= 7.3)
|
* cuDNN 8.2.1 (or >= 8.0.4)
|
||||||
* TensorRT 7.2.0 (or >=5)
|
* TensorRT 8.0.3 (or >=7.2)
|
||||||
* OpenCV 4.5.2 (or >=4)
|
* OpenCV 4.5.4 (or >=4)
|
||||||
* cmake 3.21 (or >= 3.15)
|
* cmake 3.21 (or >= 3.15)
|
||||||
* yaml-cpp 0.5.2
|
* yaml-cpp 0.5.2
|
||||||
* eigen3 3.3.4
|
* eigen3 3.3.4
|
||||||
@@ -101,7 +100,8 @@ To compile and install OpenCV4 with contrib us the script ```install_OpenCV4.sh`
|
|||||||
```
|
```
|
||||||
bash scripts/install_OpenCV4.sh
|
bash scripts/install_OpenCV4.sh
|
||||||
```
|
```
|
||||||
When using openCV not compiled with contrib, comment the definition of OPENCV_CUDACONTRIBCONTRIB in include/tkDNN/DetectionNN.h. When commented, the preprocessing of the networks is computed on the CPU, otherwise on the GPU. In the latter case some milliseconds are saved in the end-to-end latency.
|
If you have OpenCV compiled with cuda and contrib and want to use it with tkDNN pass ```ENABLE_OPENCV_CUDA_CONTRIB=ON``` flag when compiling tkDBB
|
||||||
|
. If the flag is not passed,the preprocessing of the networks is computed on the CPU, otherwise on the GPU. In the latter case some milliseconds are saved in the end-to-end latency.
|
||||||
|
|
||||||
## How to compile this repo
|
## How to compile this repo
|
||||||
Build with cmake. If using Ubuntu 18.04 a new version of cmake is needed (3.15 or above).
|
Build with cmake. If using Ubuntu 18.04 a new version of cmake is needed (3.15 or above).
|
||||||
@@ -137,9 +137,9 @@ For specific details on how to run:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## tkDNN on Windows 10/11 (experimental)
|
## tkDNN on Windows 10 or Windows 11
|
||||||
|
|
||||||
For specific details on how to run tkDNN on Windows 10 see [HERE](./docs/windows.md).
|
For specific details on how to run tkDNN on Windows 10/11 see [HERE](./docs/windows.md).
|
||||||
|
|
||||||
## Existing tests and supported networks
|
## Existing tests and supported networks
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -1,16 +1,14 @@
|
|||||||
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
|
FROM nvidia/cuda:11.3.1-devel-ubuntu20.04
|
||||||
LABEL maintainer "Francesco Gatti"
|
LABEL maintainer "Francesco Gatti"
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ADD nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb /tmp/trt.deb
|
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 apt-get update && dpkg -i /tmp/trt.deb && rm /tmp/trt.deb && apt-get update
|
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 apt install -y libnvinfer7=7.0.0-1+cuda10.2 libnvinfer-dev=7.0.0-1+cuda10.2
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive apt install -y git wget libeigen3-dev libyaml-cpp-dev
|
|
||||||
RUN cd /tmp && \
|
RUN cd /tmp && \
|
||||||
wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-x86_64.sh && \
|
wget https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-Linux-x86_64.sh && \
|
||||||
chmod +x cmake-3.17.3-Linux-x86_64.sh && \
|
chmod +x cmake-3.21.4-Linux-x86_64.sh && \
|
||||||
./cmake-3.17.3-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license && \
|
./cmake-3.21.4-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license && \
|
||||||
rm ./cmake-3.17.3-Linux-x86_64.sh
|
rm ./cmake-3.21.4-Linux-x86_64.sh
|
||||||
|
ENV NVIDIA_VISIBLE_DEVICES all
|
||||||
RUN echo "INSTALL OPENCV"
|
RUN echo "INSTALL OPENCV"
|
||||||
RUN apt-get install -y build-essential \
|
RUN apt-get install -y build-essential \
|
||||||
unzip \
|
unzip \
|
||||||
@@ -26,20 +24,21 @@ RUN apt-get install -y build-essential \
|
|||||||
libx264-dev \
|
libx264-dev \
|
||||||
libgtk-3-dev \
|
libgtk-3-dev \
|
||||||
libatlas-base-dev \
|
libatlas-base-dev \
|
||||||
gfortran \
|
gfortran-9 \
|
||||||
|
libtbb-dev \
|
||||||
libgstreamer1.0-dev \
|
libgstreamer1.0-dev \
|
||||||
libgstreamer-plugins-base1.0-dev \
|
libgstreamer-plugins-base1.0-dev \
|
||||||
libdc1394-22-dev \
|
libdc1394-22-dev \
|
||||||
libavresample-dev
|
libavresample-dev
|
||||||
RUN cd && wget https://github.com/opencv/opencv/archive/4.3.0.tar.gz && tar -xf 4.3.0.tar.gz && rm *.tar.gz
|
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.3.0.tar.gz && tar -xf 4.3.0.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 && \
|
RUN cd && \
|
||||||
cd opencv-4.3.0 && mkdir build && cd build && \
|
cd opencv-4.5.4 && mkdir build && cd build && \
|
||||||
cmake -D CMAKE_BUILD_TYPE=RELEASE \
|
cmake -D CMAKE_BUILD_TYPE=RELEASE \
|
||||||
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
||||||
-D INSTALL_PYTHON_EXAMPLES=OFF \
|
-D INSTALL_PYTHON_EXAMPLES=OFF \
|
||||||
-D INSTALL_C_EXAMPLES=OFF \
|
-D INSTALL_C_EXAMPLES=OFF \
|
||||||
-D OPENCV_EXTRA_MODULES_PATH='~/opencv_contrib-4.3.0/modules' \
|
-D OPENCV_EXTRA_MODULES_PATH='~/opencv_contrib-4.5.4/modules' \
|
||||||
-D BUILD_EXAMPLES=OFF \
|
-D BUILD_EXAMPLES=OFF \
|
||||||
-D WITH_CUDA=ON \
|
-D WITH_CUDA=ON \
|
||||||
-D CUDA_ARCH_BIN=7.2 \
|
-D CUDA_ARCH_BIN=7.2 \
|
||||||
@@ -47,6 +46,7 @@ RUN cd && \
|
|||||||
-D ENABLE_FAST_MATH=ON \
|
-D ENABLE_FAST_MATH=ON \
|
||||||
-D CUDA_FAST_MATH=ON \
|
-D CUDA_FAST_MATH=ON \
|
||||||
-D WITH_CUBLAS=ON \
|
-D WITH_CUBLAS=ON \
|
||||||
|
-D WITH_OPENMP=ON \
|
||||||
-D WITH_LIBV4L=ON \
|
-D WITH_LIBV4L=ON \
|
||||||
-D WITH_GSTREAMER=ON \
|
-D WITH_GSTREAMER=ON \
|
||||||
-D WITH_GSTREAMER_0_10=OFF \
|
-D WITH_GSTREAMER_0_10=OFF \
|
||||||
|
|||||||
+7
-7
@@ -32,7 +32,7 @@ make
|
|||||||
|
|
||||||
Once you have successfully created your rt file, run the demo(yolo) :
|
Once you have successfully created your rt file, run the demo(yolo) :
|
||||||
```
|
```
|
||||||
./demo yolo4_fp32.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/cococ.names
|
./demo yolo4_fp32.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||||
```
|
```
|
||||||
|
|
||||||
To run demo for mobilenet and centernet for the created rt file :
|
To run demo for mobilenet and centernet for the created rt file :
|
||||||
@@ -67,9 +67,9 @@ N.B. By default it is used FP32 inference
|
|||||||
To run the demo with FP16 inference follow these steps (example with yolov3):
|
To run the demo with FP16 inference follow these steps (example with yolov3):
|
||||||
```
|
```
|
||||||
export TKDNN_MODE=FP16 # set the half floating point optimization
|
export TKDNN_MODE=FP16 # set the half floating point optimization
|
||||||
rm yolo3_fp16.rt # be sure to delete(or move) old tensorRT files
|
rm yolo4_fp16.rt # be sure to delete(or move) old tensorRT files
|
||||||
./test_yolo3 # run the yolo test (is slow)
|
./test_yolo4 # run the yolo test (is slow)
|
||||||
./demo yolo3_fp16.rt ../demo/yolo_test.mp4 y
|
./demo yolo4_fp16.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||||
```
|
```
|
||||||
N.B. Using FP16 inference will lead to some errors in the results (first or second decimal).
|
N.B. Using FP16 inference will lead to some errors in the results (first or second decimal).
|
||||||
|
|
||||||
@@ -92,9 +92,9 @@ Then a complete example using yolo3 and COCO dataset would be:
|
|||||||
export TKDNN_MODE=INT8
|
export TKDNN_MODE=INT8
|
||||||
export TKDNN_CALIB_LABEL_PATH=../demo/COCO_val2017/all_labels.txt
|
export TKDNN_CALIB_LABEL_PATH=../demo/COCO_val2017/all_labels.txt
|
||||||
export TKDNN_CALIB_IMG_PATH=../demo/COCO_val2017/all_images.txt
|
export TKDNN_CALIB_IMG_PATH=../demo/COCO_val2017/all_images.txt
|
||||||
rm yolo3_int8.rt # be sure to delete(or move) old tensorRT files
|
rm yolo4_int8.rt # be sure to delete(or move) old tensorRT files
|
||||||
./test_yolo3 # run the yolo test (is slow)
|
./test_yolo4 # run the yolo test (is slow)
|
||||||
./demo yolo3_int8.rt ../demo/yolo_test.mp4 y
|
./demo yolo4_int8.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/coco.names
|
||||||
```
|
```
|
||||||
N.B.
|
N.B.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
### Dependencies-Windows
|
### Dependencies-Windows
|
||||||
This branch should work on every NVIDIA GPU supported in windows with the following dependencies:
|
This branch should work on every NVIDIA GPU supported in windows with the following dependencies:
|
||||||
|
|
||||||
* WINDOWS 10 1803 or HIGHER
|
* WINDOWS 10 1803/WINDOWS 11 or HIGHER
|
||||||
* CUDA 11.2
|
* CUDA 11.2
|
||||||
* CUDNN 8.1.1
|
* CUDNN 8.1.1
|
||||||
* TENSORRT 7.2.3
|
* TENSORRT 7.2.3
|
||||||
|
|||||||
@@ -27,10 +27,14 @@ sudo apt-get install -y build-essential \
|
|||||||
libgstreamer1.0-dev \
|
libgstreamer1.0-dev \
|
||||||
libgstreamer-plugins-base1.0-dev \
|
libgstreamer-plugins-base1.0-dev \
|
||||||
libdc1394-22-dev \
|
libdc1394-22-dev \
|
||||||
libavresample-dev
|
libavresample-dev \
|
||||||
|
libtbb-dev \
|
||||||
|
|
||||||
git clone https://github.com/opencv/opencv.git
|
git clone https://github.com/opencv/opencv.git
|
||||||
|
cd opencv && git checkout 4.5.4 && cd ..
|
||||||
git clone https://github.com/opencv/opencv_contrib.git
|
git clone https://github.com/opencv/opencv_contrib.git
|
||||||
|
cd opencv_contrib && git checkout 4.5.4 && cd ..
|
||||||
|
|
||||||
|
|
||||||
python3 -m venv opencv4
|
python3 -m venv opencv4
|
||||||
source opencv4/bin/activate
|
source opencv4/bin/activate
|
||||||
@@ -56,6 +60,8 @@ cmake -D CMAKE_BUILD_TYPE=RELEASE \
|
|||||||
-D WITH_GSTREAMER=ON \
|
-D WITH_GSTREAMER=ON \
|
||||||
-D WITH_GSTREAMER_0_10=OFF \
|
-D WITH_GSTREAMER_0_10=OFF \
|
||||||
-D WITH_TBB=ON \
|
-D WITH_TBB=ON \
|
||||||
|
-D WITH_OPENGL=ON \
|
||||||
|
-D WITH_VULKAN=ON \
|
||||||
../
|
../
|
||||||
|
|
||||||
make -j4
|
make -j4
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ int main()
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//convert network to tensorRT
|
//convert network to tensorRT
|
||||||
tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("dla34_cnet"));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(&net, net.getNetworkRTName("dla34_cnet"));
|
||||||
|
|
||||||
tk::dnn::dataDim_t dim1 = dim; //input dim
|
tk::dnn::dataDim_t dim1 = dim; //input dim
|
||||||
printCenteredTitle(" CUDNN inference ", '=', 30);
|
printCenteredTitle(" CUDNN inference ", '=', 30);
|
||||||
@@ -509,7 +509,7 @@ int main()
|
|||||||
{
|
{
|
||||||
dim2.print();
|
dim2.print();
|
||||||
TKDNN_TSTART
|
TKDNN_TSTART
|
||||||
netRT.infer(dim2, data);
|
netRT->infer(dim2, data);
|
||||||
TKDNN_TSTOP
|
TKDNN_TSTOP
|
||||||
dim2.print();
|
dim2.print();
|
||||||
}
|
}
|
||||||
@@ -528,7 +528,7 @@ int main()
|
|||||||
|
|
||||||
dnnType *cudnn_out, *rt_out;
|
dnnType *cudnn_out, *rt_out;
|
||||||
cudnn_out = outs[i]->dstData;
|
cudnn_out = outs[i]->dstData;
|
||||||
rt_out = (dnnType *)netRT.buffersRT[i+out_count];
|
rt_out = (dnnType *)netRT->buffersRT[i+out_count];
|
||||||
// there is the maxpool. It isn't an output but it is necessary for the process section
|
// there is the maxpool. It isn't an output but it is necessary for the process section
|
||||||
if(i==0)
|
if(i==0)
|
||||||
out_count ++;
|
out_count ++;
|
||||||
@@ -540,6 +540,6 @@ int main()
|
|||||||
std::cout<<"CUDNN vs TRT ";
|
std::cout<<"CUDNN vs TRT ";
|
||||||
ret_cudnn_tensorrt |= checkResult(odim, cudnn_out, rt_out) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
ret_cudnn_tensorrt |= checkResult(odim, cudnn_out, rt_out) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||||
}
|
}
|
||||||
netRT.destroy();
|
netRT->destroy();
|
||||||
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
|
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user