Skip to content

Commit 5d72c5a

Browse files
authored
Add DenseNet121 (wang-xinyu#460)
* add: densenet * update readme
1 parent e381ae5 commit 5d72c5a

File tree

4 files changed

+985
-0
lines changed

4 files changed

+985
-0
lines changed

densenet/CMakeLists.txt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
# set the project name
4+
project(densenet)
5+
6+
add_definitions(-std=c++11)
7+
8+
# get main project dir to include common files
9+
get_filename_component(MAIN_DIR ../ ABSOLUTE)
10+
11+
# When enabled the static version of the
12+
# CUDA runtime library will be used in CUDA_LIBRARIES
13+
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
14+
15+
# specify the C++ standard
16+
set(CMAKE_CXX_STANDARD 11)
17+
set(CMAKE_CXX_STANDARD_REQUIRED True)
18+
set(CMAKE_BUILD_TYPE Debug)
19+
20+
# include
21+
22+
# include and link cuda
23+
include_directories(/usr/local/cuda/include)
24+
link_directories(/usr/local/cuda/lib64)
25+
26+
# include and link tensorrt
27+
include_directories(/usr/include/x86_64-linux-gnu)
28+
link_directories(/usr/lib/x86_64-linux-gnu)
29+
30+
# add the executable
31+
add_executable(densenet ${PROJECT_SOURCE_DIR}/densenet121.cpp)
32+
33+
target_link_libraries(densenet nvinfer)
34+
target_link_libraries(densenet cudart)
35+
36+
add_definitions(-O2 -pthread)

densenet/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Densenet121
2+
3+
The Pytorch implementation is [makaveli10/densenet](https://github.com/makaveli10/torchtrtz/tree/main/densenet).
4+
The tensorrt implemenation is taken from [makaveli10/cpptensorrtz](https://github.com/makaveli10/cpptensorrtz/).
5+
6+
## How to Run
7+
8+
1. generate densenet121.wts from pytorch
9+
10+
```
11+
git clone https://github.com/wang-xinyu/tensorrtx.git
12+
git clone https://github.com/makaveli10/torchtrtz.git
13+
14+
// go to torchtrtz/densenet
15+
// Enter these two commands to create densenet121.wts
16+
$ python models.py
17+
$ python gen_trtwts.py
18+
```
19+
20+
2. build densenet and run
21+
22+
```
23+
// put densenet121.wts into tensorrtx/densenet
24+
// go to tensorrtx/densenet
25+
mkdir build
26+
cd build
27+
cmake ..
28+
make
29+
sudo ./densenet -s // serialize model to file i.e. 'LPRnet.engine'
30+
sudo ./densenet -d // deserialize model and run inference
31+
```
32+
33+
3. Verify output from [torch impl](https://github.com/makaveli10/torchtrtz/blob/main/densenet/README.md)
34+
TensorRT output[:5]:
35+
```
36+
[-0.587389, -0.329202, -1.83404, -1.89935, -0.928404]
37+
```
38+

0 commit comments

Comments
 (0)