auto download
This commit is contained in:
+12
-1
@@ -1,7 +1,18 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
project (tkDNN)
|
project (tkDNN)
|
||||||
|
|
||||||
|
set(BUILD_DEPS true CACHE BOOL "If true download deps")
|
||||||
|
|
||||||
|
if( ${BUILD_DEPS} )
|
||||||
|
message("Launching pre-build dependency installer script...")
|
||||||
|
|
||||||
|
execute_process (COMMAND bash -c "bash build_models.sh download"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||||
|
|
||||||
|
set(BUILD_DEPS false CACHE BOOL "If true download deps" FORCE)
|
||||||
|
message("Finished dowloading test weights")
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(CUDA QUIET REQUIRED)
|
find_package(CUDA QUIET REQUIRED)
|
||||||
|
|
||||||
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS})
|
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS})
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
# tkDNN
|
# tkDNN
|
||||||
tkDNN is a Deep Neural Network library built with cuDNN primitives specifically thought to work on NVIDIA TK1 board.<br>
|
tkDNN is a Deep Neural Network library built with cuDNN primitives specifically thought to work on NVIDIA TK1 board.<br>
|
||||||
The main scope is to do high performance inference on already trained models.
|
The main scope is to do high performance inference on already trained models.
|
||||||
Currently supports the following layers:
|
|
||||||
|
|
||||||
* Dense, fully interconnected
|
this branch is actually work on every NVIDIA GPU that support the dependencies:
|
||||||
* Activation (RELU, ELU, SIGMOID, TANH)
|
* CUDA 8
|
||||||
* Convolutional 2D
|
* CUDNN 6
|
||||||
* Convolutional 3D
|
* TENSORRT 2
|
||||||
* Max and Average Pooling
|
|
||||||
* Flatten
|
|
||||||
* Data preprocessing
|
|
||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
The recommended workflow follow these step:
|
The recommended workflow follow these step:
|
||||||
@@ -26,60 +22,14 @@ cd build
|
|||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
during the cmake configuration it will be dowloaded the weights needed for running
|
||||||
|
the tests
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
There is a ready to use example on *test* directory, to try it you must generate the weights with Keras
|
Assumiung you have correctly builded the library these are the test ready to exec:
|
||||||
```
|
* test_simple: a simple convolutional and dense network (CUDNN only)
|
||||||
cd tests
|
* test_mnist: the famous mnist netwok (CUDNN and TENSORRT)
|
||||||
python test_model.py
|
* test_mnistRT: the mnist network hardcoded in using tensorRT apis (TENSORRT only)
|
||||||
```
|
* test_yolo: YOLO detection network (CUDNN and TENSORRT)
|
||||||
And then execute the inference on build directory
|
* test_yolo_tiny: smaller version of YOLO (CUDNN and TENSRRT)
|
||||||
```
|
|
||||||
cd build
|
|
||||||
./tkDNNtest
|
|
||||||
```
|
|
||||||
this should output the same prediction as Keras.
|
|
||||||
|
|
||||||
## Simple example
|
|
||||||
Here is a example of the entire workflow on a simple model.
|
|
||||||
Using the following Keras model save it to a file
|
|
||||||
```python
|
|
||||||
model = Sequential()
|
|
||||||
model.add(Reshape((20, 1), input_shape=(20)))
|
|
||||||
model.add(Dense(256))
|
|
||||||
model.compile()
|
|
||||||
|
|
||||||
# save model
|
|
||||||
model.save("path/to/model.h5")
|
|
||||||
```
|
|
||||||
|
|
||||||
After the model is created the weights can be exported for tkDNN inference
|
|
||||||
```
|
|
||||||
python weights_exporter model.h5 dense --output=weights/path
|
|
||||||
```
|
|
||||||
the exporter take as arguments, in order:
|
|
||||||
* input model
|
|
||||||
* layer type ["dense", "conv2d", conv3d"]
|
|
||||||
* { layer type ["dense", "conv2d", conv3d"] for each layer to export }
|
|
||||||
* optional argument --output define path where export weights
|
|
||||||
|
|
||||||
Then we can create a c++ program to do inference on tk1
|
|
||||||
```c++
|
|
||||||
#include<tkdnn.h> //library include
|
|
||||||
|
|
||||||
//Network object
|
|
||||||
tkDNN::Network net;
|
|
||||||
//input dimension
|
|
||||||
tkDNN::dataDim_t dim(1, 20, 1, 1, 1);
|
|
||||||
//Dense layer
|
|
||||||
tkDNN::Dense d0(&net, dim, 256, "weights/path", "bias/path");
|
|
||||||
|
|
||||||
//here load the input data to CUDA
|
|
||||||
//value_type is an alias of "float"
|
|
||||||
value_type *data_d = [...]
|
|
||||||
|
|
||||||
//do inference
|
|
||||||
value_type *output_d = d0.infer(dim, data_d);
|
|
||||||
//dim will be updated with the output dimension
|
|
||||||
```
|
|
||||||
The result is finally stored on output_d in device memory.
|
|
||||||
Reference in New Issue
Block a user