Elffuss BraidHub

kikocis/ncnn public

master · 4.3 KiBRenderedRawPermalink
1### param is too old, please regenerate
2
3Your model file is being the old format converted by an old caffe2ncnn tool.
4
5Checkout the latest ncnn code, build it and regenerate param and model binary files, and that should work.
6
7Make sure that your param file starts with the magic number 7767517.
8
9you may find more info on [use-ncnn-with-alexnet](use-ncnn-with-alexnet)
10
11If the original model is missing, you can try to manually fix the layer specific parameters in param file
12
131. **Softmax** append `1=1`
14
15before
16```
17Softmax xxx 1 1 in out ...
18```
19after
20```
21Softmax xxx 1 1 in out ... 1=1
22```
23
242. **Reduction** minus all axes value by 1 (except the leading array count) and append `5=1`
25
26before
27```
28Reduction xxx 1 1 in out ... -23303=2,2,3 ...
29```
30after
31```
32Reduction xxx 1 1 in out ... -23303=2,1,2 ... 5=1
33```
34
35### find_blob_index_by_name XYZ failed
36
37That means ncnn couldn't find the XYZ blob in the network.
38
39You shall call Extractor::input()/extract() by blob name instead of layer name.
40
41For models loaded from binary param file or external memory, you shall call Extractor::input()/extract() by the enum defined in xxx.id.h because all the visible string literals have been stripped in binary form.
42
43This error usually happens when the input layer is not properly converted.
44
45You shall upgrade caffe prototxt/caffemodel before converting it to ncnn. Following snippet type shall be ok.
46
47```
48layer {
49 name: "data"
50 type: "Input"
51 top: "data"
52 input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 } }
53}
54```
55
56you may find more info on [use-ncnn-with-alexnet](use-ncnn-with-alexnet).
57
58### layer XYZ not exists or registered
59
60Your network contains some operations that are not implemented in ncnn.
61
62You may implement them as custom layer followed in [how-to-implement-custom-layer-step-by-step](how-to-implement-custom-layer-step-by-step).
63
64Or you could simply register them as no-op if you are sure those operations make no sense.
65
66```cpp
67class Noop : public ncnn::Layer {};
68DEFINE_LAYER_CREATOR(Noop)
69
70net.register_custom_layer("LinearRegressionOutput", Noop_layer_creator);
71net.register_custom_layer("MAERegressionOutput", Noop_layer_creator);
72```
73
74### fopen XYZ.param/XYZ.bin failed
75
76File not found or not readable. Make sure that XYZ.param/XYZ.bin is accessible.
77
78### network graph not ready
79
80You shall call Net::load_param() first, then Net::load_model().
81
82This error may also happens when Net::load_param() failed, but not properly handled.
83
84For more information about the ncnn model load api, see [ncnn-load-model](ncnn-load-model)
85
86### memory not 32-bit aligned at XYZ
87
88The pointer passed to Net::load_param() or Net::load_model() is not 32bit aligned.
89
90In practice, the head pointer of std::vector<unsigned char> is not guaranteed to be 32bit aligned.
91
92you can store your binary buffer in ncnn::Mat structure, its internal memory is aligned.
93
94### undefined reference to '__kmpc_XYZ_XYZ'
95
96use clang for building android shared library
97
98comment the following line in your Application.mk
99```
100NDK_TOOLCHAIN_VERSION := 4.9
101```
102
103### crash on android with '__kmp_abort_process'
104
105This usually happens if you bundle multiple shared library with openmp linked
106
107It is actually an issue of the android ndk https://github.com/android/ndk/issues/1028
108
109On old android ndk, modify the link flags as
110
111```
112-Wl,-Bstatic -lomp -Wl,-Bdynamic
113```
114
115For recent ndk >= 21
116
117```
118-fstatic-openmp
119```
120
121### dlopen failed: library "libomp.so" not found
122
123Newer android ndk defaults to dynamic openmp runtime
124
125modify the link flags as
126
127```
128-fstatic-openmp -fopenmp
129```
130
131### crash when freeing a ncnn dynamic library(*.dll/*.so) built with openMP
132
133for optimal performance, the openmp threadpool spin waits for about a second prior to shutting down in case more work becomes available.
134
135If you unload a dynamic library that's in the process of spin-waiting, it will crash in the manner you see (most of the time).
136
137Just set OMP_WAIT_POLICY=passive in your environment, before calling loadlibrary. or Just wait a few seconds before calling freelibrary.
138
139You can also use the following method to set environment variables in your code:
140
141for msvc++:
142
143```
144SetEnvironmentVariable(_T("OMP_WAIT_POLICY"), _T("passive"));
145```
146
147for g++:
148
149```
150setenv("OMP_WAIT_POLICY", "passive", 1)
151```
152
153reference: https://stackoverflow.com/questions/34439956/vc-crash-when-freeing-a-dll-built-with-openmp