File tree Expand file tree Collapse file tree 7 files changed +1159
-0
lines changed Expand file tree Collapse file tree 7 files changed +1159
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ Following models are implemented.
5353
5454| Name | Description |
5555| -| -|
56+ | [ mlp] ( ./mlp ) | the very basic model for starters, properly documented |
5657| [ lenet] ( ./lenet ) | the simplest, as a "hello world" of this project |
5758| [ alexnet] ( ./alexnet ) | easy to implement, all layers are supported in tensorrt |
5859| [ googlenet] ( ./googlenet ) | GoogLeNet (Inception v1) |
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.14) # change the version, if asked by compiler
2+ project (mlp)
3+
4+ set (CMAKE_CXX_STANDARD 14)
5+
6+ # include and link dirs of tensorrt, you need adapt them if yours are different
7+ include_directories (/usr/include /x86_64-linux-gnu/)
8+ link_directories (/usr/lib/x86_64-linux-gnu/)
9+
10+ # include and link dirs of cuda for inference
11+ include_directories (/usr/local/cuda/include )
12+ link_directories (/usr/local/cuda/lib64)
13+
14+ # create link for executable files
15+ add_executable (mlp mlp.cpp)
16+
17+ # perform linking with nvinfer libraries
18+ target_link_libraries (mlp nvinfer)
19+
20+ # link with cuda libraries for Inference
21+ target_link_libraries (mlp cudart)
22+
23+ add_definitions (-O2 -pthread)
24+
Original file line number Diff line number Diff line change 1+ # MLP
2+
3+ MLP is the most basic net in this tensorrtx project for starters. You can learn the basic procedures of building
4+ TensorRT app from the provided APIs. The process of building a TensorRT engine explained in the chart below.
5+
6+ ![ TensorRT Image] ( https://user-images.githubusercontent.com/33795294/148565279-795b12da-5243-4e7e-881b-263eb7658683.jpg )
7+
8+ ## Helper Files
9+
10+ ` logging.h ` : A logger file for using NVIDIA TRT API (mostly same for all models)
11+
12+ ` mlp.wts ` : Converted weight file (simple file, you can open and check it)
13+
14+ ## TensorRT C++ API
15+
16+ ```
17+ // 1. generate mlp.wts from https://github.com/wang-xinyu/pytorchx/tree/master/mlp -- or use the given .wts file
18+
19+ // 2. put mlp.wts into tensorrtx/mlp (if using the generated weights)
20+
21+ // 3. build and run
22+
23+ cd tensorrtx/mlp
24+
25+ mkdir build
26+
27+ cd build
28+
29+ cmake ..
30+
31+ make
32+
33+ sudo ./mlp -s // serialize model to plan file i.e. 'mlp.engine'
34+
35+ sudo ./mlp -d // deserialize plan file and run inference
36+ ```
37+
38+ ## TensorRT Python API
39+
40+ ```
41+ # 1. Generate mlp.wts from https://github.com/wang-xinyu/pytorchx/tree/master/mlp -- or use the given .wts file
42+
43+ # 2. Put mlp.wts into tensorrtx/mlp (if using the generated weights)
44+
45+ # 3. Install Python dependencies (tensorrt/pycuda/numpy)
46+
47+ # 4. Run
48+
49+ cd tensorrtx/mlp
50+
51+ python mlp.py -s # serialize model to plan file, i.e. 'mlp.engine'
52+
53+ python mlp.py -d # deserialize plan file and run inference
54+ ```
55+
56+ ## Note
57+ It also supports the latest CUDA-11.4 and TensorRT-8.2.x
You can’t perform that action at this time.
0 commit comments