Update README.md,windows.md and demo.cpp

Small fixes in DeformableConvRT.cpp
This commit is contained in:
perseusdg
2021-11-09 13:37:26 +05:30
parent d2d44e9e92
commit 744396fb0e
6 changed files with 61 additions and 38 deletions
+12 -6
View File
@@ -3,10 +3,12 @@ project(tkDNN)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
option(ENABLE_OPENCV_CUDA_CONTRIB "Enable OpenCV CUDA Contrib" OFF )
find_package(CUDA 9.0 REQUIRED)
if (CUDA_FOUND)
#Get CUDA compute capability
set(OUTPUTFILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cuda_script) # No suffix required
execute_process(COMMAND "rm ${OUTPUTFILE}")
set(CUDAFILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/getCudaArch.cu)
execute_process(COMMAND ${CUDA_NVCC_EXECUTABLE} -lcuda ${CUDAFILE} -o ${OUTPUTFILE})
execute_process(COMMAND ${OUTPUTFILE}
@@ -25,10 +27,7 @@ if (CUDA_FOUND)
message(STATUS "CUDA Path: ${CUDA_TOOLKIT_ROOT_DIR}")
message(STATUS "CUDA Libararies: ${CUDA_LIBRARIES}")
message(STATUS "CUDA Performance Primitives: ${CUDA_npp_LIBRARY}")
set(CUDA_NVCC_FLAGS "${ARCH}")
add_definitions(-DGPU) #You may not require this
else()
message(WARNING ${ARCH})
endif()
@@ -51,7 +50,7 @@ endif()
if(WIN32)
if(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_CXX_FLAGS "/O2 /FS /EHsc /Md")
set(CMAKE_CXX_FLAGS "/O2 /FS /EHsc /MD")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --maxrregcount=32)
endif()
@@ -70,7 +69,7 @@ if(DEBUG)
endif()
if(TKDNN_PATH)
message("SET TKDNN_PATH:"${TKDNN_PATH})
message("SET TKDNN_PATH:" ${TKDNN_PATH})
add_definitions(-DTKDNN_PATH="${TKDNN_PATH}")
else()
add_definitions(-DTKDNN_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
@@ -105,6 +104,13 @@ include_directories(${EIGEN3_INCLUDE_DIR})
find_package(OpenCV REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV")
if(ENABLE_OPENCV_CUDA_CONTRIB)
if (OpenCV_FOUND)
find_package(OpenCV COMPONENTS cudawarping cudaarithm)
add_compile_definitions(OPENCV_CUDACONTRIB)
message("OpenCV Cuda Contrib modules found")
endif()
endif()
# if(OpenCV_CUDA_VERSION)
# add_compile_definitions(OPENCV_CUDACONTRIB)
# endif()
+5 -4
View File
@@ -104,14 +104,15 @@ 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.
## 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).
On both linux and windows ,the ```CMAKE_BUILD_TYPE``` variable needs to be defined as either ```Release``` or ```Debug```.
```
git clone https://github.com/ceccocats/tkDNN
cd tkDNN
mkdir build
cd build
cmake ..
make
cmake -DCMAKE_BUILD_TYPE=Release -G"Ninja" ..
ninja
```
## Workflow
@@ -136,7 +137,7 @@ For specific details on how to run:
![demo](https://user-images.githubusercontent.com/11562617/72547657-540e7800-388d-11ea-83c6-49dfea2a0607.gif)
## tkDNN on Windows 10 (experimental)
## tkDNN on Windows 10/11 (experimental)
For specific details on how to run tkDNN on Windows 10 see [HERE](./docs/windows.md).
+6 -6
View File
@@ -45,16 +45,16 @@ int main(int argc, char *argv[]) {
char ntype = 'y';
if(argc > 2)
ntype = argv[2][0];
int n_classes = 80;
input = argv[2];
if(argc > 3)
n_classes = atoi(argv[3]);
ntype = argv[3][0];
int n_classes = 80;
if(argc > 4)
cfgPath = argv[4];
n_classes = atoi(argv[4]);
if(argc > 5)
namePath = argv[5];
cfgPath = argv[5];
if(argc > 6)
input = argv[6];
namePath = argv[6];
int n_batch = 1;
if(argc > 7)
n_batch = atoi(argv[7]);
+19 -11
View File
@@ -26,27 +26,35 @@ rm yolo4_fp32.rt # be sure to delete(or move) old tensorRT files
```
If you get problems in the creation, try to check the error activating the debug of TensorRT in this way:
```
cmake .. -DDEBUG=True
cmake .. -DCMAKE_BUILD_TYPE=Debug -DDEBUG=True
make
```
Once you have successfully created your rt file, run the demo:
Once you have successfully created your rt file, run the demo(yolo) :
```
./demo yolo4_fp32.rt ../demo/yolo_test.mp4 y
./demo yolo4_fp32.rt ../demo/yolo_test.mp4 y 80 ../tests/darknet/cfg/yolo4.cfg ../tests/darknet/names/cococ.names
```
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> <n-batches> <show-flag> <conf-thresh>
./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
* ```<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.
* ```<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.
N.B. By default it is used FP32 inference
+16 -9
View File
@@ -7,17 +7,18 @@
- [Run the demo on Windows](#run-the-demo-on-windows)
- [FP16 inference windows](#fp16-inference-windows)
- [INT8 inference windows](#int8-inference-windows)
- [Run tkDNN on WSL2 with cuda](#tkdnn-on-cuda-wsl)
- [Known issues with tkDNN on Windows](#known-issues-with-tkdnn-on-windows)
### Dependencies-Windows
This branch should work on every NVIDIA GPU supported in windows with the following dependencies:
* WINDOWS 10 1803 or HIGHER
* CUDA 10.0 (Recommended CUDA 11.2 )
* CUDNN 7.6 (Recommended CUDNN 8.1.1 )
* TENSORRT 6.0.1 (Recommended TENSORRT 7.2.3.4 )
* OPENCV 3.4 (Recommended OPENCV 4.2.0 )
* MSVC 16.7
* CUDA 11.2
* CUDNN 8.1.1
* TENSORRT 7.2.3
* OPENCV 4.2
* MSVC 16.9+
* YAML-CPP
* EIGEN3
* 7ZIP (ADD TO PATH)
@@ -58,7 +59,7 @@ To run the object detection file create .rt file bu running:
Once the rt file has been successfully create,run the demo using the following command:
```
.\demo.exe yolo4tiny_fp32.rt ..\demo\yolo_test.mp4 y
.\demo.exe yolo4_fp32.rt ..\demo\yolo_test.mp4 y 80 ..\tests\darknet\cfg\yolo4.cfg ..\tests\darknet\names\cococ.names
```
For general info on more demo paramters,check Run the demo section on top
To run the test_all_tests.sh on windows,use git bash or msys2
@@ -85,11 +86,17 @@ del /f yolo4tiny_int8.rt # be sure to delete(or move) old tensorRT files
```
### Run tkDNN on WSL2 with cuda
tkDNN works on wsl2 with cuda,although not all networks (centernet,mobilenet) work properly.
If you encounter issues with running the network as a result of driver not found or cuda launch error,running the following command should solve the issue
```cp /usr/lib/wsl/lib/lib* /usr/lib/x86_64-linux-gnu/ ```
### Known issues with tkDNN on Windows
Mobilenet and Centernet demos work properly only when built with msvc 16.7 in Release Mode,when built in debug mode for the mentioned networks one might encounter opencv assert errors
In theory all models (centernet,mobilenet,darknet,centertrack,cnet3d and shelfnet) should work on Windows.
All Darknet models work properly with demo using MSVC version(16.7-16.9)
On pascal cards(sm 6x) ,nvidia cuda wsl driver 510.06 don't work well with tkDNN both on windows and cuda wsl , Nvidia drivers >465+ and < 500 are completely supported .
It is recommended to use Nvidia Driver(465+),Cuda unknown errors have been observed when using older drivers on pascal(SM 61) devices.
+3 -2
View File
@@ -65,7 +65,6 @@ DeformableConvRT::~DeformableConvRT() {
checkCuda( cudaFree(offset) );
checkCuda( cudaFree(mask) );
checkCuda( cudaFree(ones_d2) );
cublasDestroy(handle);
}
DeformableConvRT::DeformableConvRT(const void *data, size_t length) {
@@ -229,7 +228,9 @@ void DeformableConvRT::serialize(void *buffer) const NOEXCEPT {
assert(buf == a + getSerializationSize());
}
void DeformableConvRT::destroy() NOEXCEPT { delete this; }
void DeformableConvRT::destroy() NOEXCEPT {
delete this;
}
const char *DeformableConvRT::getPluginNamespace() const NOEXCEPT {