Elffuss BraidHub

kikocis/ncnn public

master · 9.6 KiBRenderedRawPermalink
1
2
3# How to join the technical Community Groups with QQ ?
4
5- Open QQ -> click the group chat search-> search group number 637093648, enter the answer to the question: conv conv conv conv conv → join the group chat → ready to accept the Turing test(a joke)
6- Open QQ -> search Pocky group: 677104663 (lots experts), the answer to the question
7
8# How to watch the author's on live in Bilibili?
9
10- nihui:[水竹院落](https://live.bilibili.com/1264617)
11
12# Compilation
13
14- ## How to download the full source code?
15
16 git clone --recursive https://github.com/Tencent/ncnn/
17
18 or
19
20 download [ncnn-xxxxx-full-source.zip](https://github.com/Tencent/ncnn/releases)
21
22- ## How to cross-compile?How to set the cmake toolchain?
23
24 See https://github.com/Tencent/ncnn/wiki/how-to-build
25
26- ## The submodules were not downloaded! Please update submodules with "git submodule update --init" and try again
27
28 As above, download the full source code. Or follow the prompts to execute: git submodule update --init
29
30- ## Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
31
32 sudo apt-get install libprotobuf-dev protobuf-compiler
33
34- ## Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
35
36 https://github.com/Tencent/ncnn/issues/1873
37
38- ## Could not find a package configuration file provided by "OpenCV" with any of the following names: OpenCVConfig.cmake opencv-config.cmake
39
40 sudo apt-get install libopencv-dev
41
42 or customized compile and install ,with set(OpenCV_DIR {the dir OpenCVConfig.cmake exist})
43
44- ## Could not find a package configuration file provided by "ncnn" with any of the following names: ncnnConfig.cmake ncnn-config.cmake
45
46 set(ncnn_DIR { the dir ncnnConfig.cmake exist})
47
48- ## Vulkan not found,
49
50 - cmake requires version >= 3.10, otherwise there is no FindVulkan.cmake
51
52 - android-api >= 24
53
54 - macos has to run the install script first
55
56- ## How to install vulkan sdk
57
58 - See https://www.vulkan.org/tools#download-these-essential-development-tools
59 - But There was a frequent problem that the project need glslang lib in ncnn not official vulkan
60
61- ## xxx.lib not found(be specified by system/compiler)
62
63 undefined reference to __kmpc_for_static_init_4 __kmpc_for_static_fini __kmpc_fork_call ...
64
65 Need to link openmp
66
67 undefined reference to vkEnumerateInstanceExtensionProperties vkGetInstanceProcAddr vkQueueSubmit ...
68
69 need vulkan-1.lib
70
71 undefined reference to glslang::InitializeProcess() glslang::TShader::TShader(EShLanguage) ...
72
73 need glslang.lib OGLCompiler.lib SPIRV.lib OSDependent.lib
74
75 undefined reference to AAssetManager_fromJava AAssetManager_open AAsset_seek ...
76
77 Add android to find_library and target_like_libraries
78
79 find_package(ncnn)
80
81- ## undefined reference to typeinfo for ncnn::Layer
82
83 opencv rtti -> opencv-mobile
84
85- ## undefined reference to __cpu_model
86
87 upgrade compiler / libgcc_s libgcc
88
89- ## unrecognized command line option "-mavx2"
90
91 upgrade gcc
92
93- ## Why is the compiled ncnn-android library so large?
94
95 See https://github.com/Tencent/ncnn/wiki/build-for-android.zh and see How to trim smaller ncnn
96
97- ## ncnnoptimize and custom layer
98
99 ncnnoptimize first before adding a custom layer to avoid ncnnoptimize not being able to handle custom layer saves.
100
101
102- ## rtti/exceptions Conflict
103
104 The reason for the conflict is that the libraries used in the project are configured differently, so analyze whether you need to turn them on or off according to your actual situation. ncnn is ON by default, add the following two parameters when recompiling ncnn.
105 - ON: -DNCNN_DISABLE_RTTI=OFF -DNCNN_DISABLE_EXCEPTION=OFF
106 - OFF: -DNCNN_DISABLE_RTTI=ON -DNCNN_DISABLE_EXCEPTION=ON
107
108
109- ## error: undefined symbol: ncnn::Extractor::extract(char const*, ncnn::Mat&)
110
111 Possible scenarios.
112 - Try upgrading the NDK version of Android Studio
113
114
115# How do I add the ncnn library to my project and how does the cmake method work?
116
117Compile ncnn,and make install. linux/windows should set/export ncnn_DIR points to the directory containing ncnnConfig.cmake under the install directory
118
119- ## android
120
121- ## ios
122
123- ## linux
124
125- ## windows
126
127- ## macos
128
129- ## arm linux
130
131
132# Convert model issues
133
134- ## caffe
135
136 `./caffe2ncnn caffe.prototxt caffe.caffemodel ncnn.param ncnn.bin`
137
138- ## mxnet
139
140 ` ./mxnet2ncnn mxnet-symbol.json mxnet.params ncnn.param ncnn.bin`
141
142- ## darknet
143
144 [https://github.com/xiangweizeng/darknet2ncnn](https://github.com/xiangweizeng/darknet2ncnn)
145
146- ## pytorch - onnx
147
148 [use ncnn with pytorch or onnx](https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx)
149
150- ## tensorflow 1.x/2.x - keras
151
152 [https://github.com/MarsTechHAN/keras2ncnn](https://github.com/MarsTechHAN/keras2ncnn) **[@MarsTechHAN](https://github.com/MarsTechHAN)**
153
154- ## tensorflow 2.x - mlir
155
156 [Converting tensorflow2 models to ncnn via MLIR](https://zhuanlan.zhihu.com/p/152535430) **@[nihui](https://www.zhihu.com/people/nihui-2)**
157
158- ## Shape not supported yet! Gather not supported yet! Cast not supported yet!
159
160 onnx-simplifier shape
161
162- ## convertmodel
163
164 [https://convertmodel.com/](https://convertmodel.com/) **[@大老师](https://github.com/daquexian)**
165
166- ## netron
167
168 [https://github.com/lutzroeder/netron](https://github.com/lutzroeder/netron)
169
170- ## How to generate a model with fixed shape?
171
172 Input 0=w 1=h 2=c
173
174- ## why gpu can speedup
175
176- ## How to convert ncnnoptimize to fp16 model
177
178 `ncnnoptimize model.param model.bin yolov5s-opt.param yolov5s-opt.bin 65536`
179
180- ## How to use ncnnoptimize checking the FLOPS / memory usage of your model
181
182- ## How to modify the model to support dynamics shape?
183
184 Interp Reshape
185
186- ## How to convert a model into code embedded in a program?
187
188 use ncnn2mem
189
190- ## How to encrypt the model?
191
192 See https://zhuanlan.zhihu.com/p/268327784
193
194- ## The ncnn model transferred under Linux, Windows/MacOS/Android/... Can I use it directly?
195
196 Yes, for all platforms
197
198- ## How to remove post-processing and export onnx?
199
200 Ref:
201
202 Referring to an article by UP <https://zhuanlan.zhihu.com/p/128974102>, step 3 is to remove the post-processing and then export the onnx, where removing the post-processing can be the result of removing the subsequent steps when testing within the project.
203
204- ## pytorch layers can't export to onnx?
205
206 Mode 1:
207
208 ONNX_ATEN_FALLBACK
209Fully customizable op, first change to one that can export (e.g. concat slice), go to ncnn and then modify param
210
211 Way 2.
212
213 You can try this with PNNX, see the following article for a general description:
214
215 1. [Windows/Linux/macOS steps for compiling PNNX](https://zhuanlan.zhihu.com/p/431833958)
216
217 2. [Learn in 5 minutes! Converting TorchScript models to ncnn models with PNNX](https://zhuanlan.zhihu.com/p/427512763)
218
219# Using
220
221- ## vkEnumeratePhysicalDevices failed -3
222
223- ## vkCreateInstance failed -9
224
225 Please upgrade your GPU driver if you meet this crash or error.
226 Here are the download sites for some brands of GPU drivers. We have provided some driver download pages here.
227 [Intel](https://downloadcenter.intel.com/product/80939/Graphics-Drivers), [AMD](https://www.amd.com/en/support), [Nvidia](https://) www.nvidia.com/Download/index.aspx)
228
229- ## ModuleNotFoundError: No module named 'ncnn.ncnn'
230
231 python setup.py develop
232
233- ## fopen nanodet-m.param failed
234
235 path should be working dir
236
237 File not found or not readable. Make sure that XYZ.param/XYZ.bin is accessible.
238
239- ## find_blob_index_by_name data / output / ... failed
240
241 layer name vs blob name
242
243 param.bin use xxx.id.h enum
244
245- ## parse magic failed
246
247- ## param is too old, please regenerate
248
249 The model maybe has problems
250
251 Your model file is being the old format converted by an old caffe2ncnn tool.
252
253 Checkout the latest ncnn code, build it and regenerate param and model binary files, and that should work.
254
255 Make sure that your param file starts with the magic number 7767517.
256
257 you may find more info on use-ncnn-with-alexnet
258
259 When adding the softmax layer yourself, you need to add 1=1
260
261- ## set_vulkan_compute failed, network use_vulkan_compute disabled
262
263 Set net.opt.use_vulkan_compute = true before load_param / load_model;
264
265- ## How to execute multiple blob inputs, multiple blob outputs?
266 Multiple execute `ex.input()` and `ex.extract()` like following
267 ```
268 ex.input("data1", in_1);
269 ex.input("data2", in_2);
270 ex.extract("output1", out_1);
271 ex.extract("output2", out_2);
272 ```
273- ## Multiple executions of Extractor extract double the calculation?
274
275 No
276
277- ## How to see the elapsed time for every layer?
278
279 cmake -DNCNN_BENCHMARK=ON ..
280
281- ## How to convert a cv::Mat CV_8UC3 BGR image
282
283 from_pixels to_pixels
284
285- ## How to convert float data to ncnn::Mat
286
287 First of all, you need to manage the memory you request yourself, at this point ncnn::Mat will not automatically free up the float data you pass over to it
288 ``` c++
289 std::vector<float> testData(60, 1.0); // use std::vector<float> to manage memory requests and releases yourself
290 ncnn::Mat in1 = ncnn::Mat(60, (void*)testData.data()).reshape(4, 5, 3); // just pass the pointer to the float data as a void*, and even specify the dimension (up says it's best to use reshape to solve the channel gap)
291 float* a = new float[60]; // New a piece of memory yourself, you need to release it later
292 ncnn::Mat in2 = ncnn::Mat(60, (void*)a).reshape(4, 5, 3).clone(); // use the same method as above, clone() to transfer data owner
293 ```