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