直接说解决问题的方法,常见的一共有几种可能。linux环境的话,上层程序员们提供了大量的工具来定位问题。
根因就是俩字:没有
所以我们能做的就是找到它为什么没有,然后把没有变成有。
动态库未找到,通过ldd命令进行定位
$ ldd -r libinfer-jna.so
linux-vdso.so.1 => (0x00007ffd6f9fa000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f08a1126000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f08a8b61000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f08a0f1e000)
libonnxruntime.so.1.11.1 => not found
libdnnl.so.2 => not found
libiomp5.so => not found
libpaddle2onnx.so.1.0.0rc2 => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f08a0d1a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f08a0afd000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f08a07f4000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f08a05de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f08a0214000)
/lib64/ld-linux-x86-64.so.2 (0x00007f08a8acf000)
undefined symbol: dnnl_primitive_attr_set_scales (./libinfer-jna.so)
undefined symbol: dnnl_primitive_destroy (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_query (./libinfer-jna.so)
undefined symbol: omp_get_thread_num, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_engine_destroy (./libinfer-jna.so)
undefined symbol: dnnl_memory_destroy (./libinfer-jna.so)
undefined symbol: dnnl_matmul_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_engine_create (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_append_sum (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_create (./libinfer-jna.so)
undefined symbol: dnnl_version (./libinfer-jna.so)
undefined symbol: omp_set_num_threads, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_init_by_strides (./libinfer-jna.so)
undefined symbol: dnnl_reduction_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_set_zero_points (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_destroy (./libinfer-jna.so)
undefined symbol: dnnl_concat_primitive_desc_create (./libinfer-jna.so)
undefined symbol: dnnl_lrn_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_reshape (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_set_output_scales (./libinfer-jna.so)
undefined symbol: GOMP_critical_start, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_primitive_execute (./libinfer-jna.so)
undefined symbol: dnnl_binary_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_get_memory_desc (./libinfer-jna.so)
undefined symbol: dnnl_softmax_backward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_inner_product_forward_desc_init (./libinfer-jna.so)
undefined symbol: omp_get_num_threads, version VERSION (./libinfer-jna.so)
undefined symbol: GOMP_critical_end, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_destroy (./libinfer-jna.so)
undefined symbol: dnnl_stream_wait (./libinfer-jna.so)
undefined symbol: dnnl_lstm_forward_desc_init_v2 (./libinfer-jna.so)
undefined symbol: dnnl_memory_set_data_handle_v2 (./libinfer-jna.so)
undefined symbol: dnnl_eltwise_backward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_logsoftmax_forward_desc_init (./libinfer-jna.so)
undefined symbol: GOMP_barrier, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_append_eltwise (./libinfer-jna.so)
undefined symbol: dnnl_fmt_tag2str (./libinfer-jna.so)
undefined symbol: dnnl_layer_normalization_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_destroy (./libinfer-jna.so)
undefined symbol: dnnl_dilated_convolution_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_query_md (./libinfer-jna.so)
undefined symbol: dnnl_lstm_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_prelu_forward_desc_init (./libinfer-jna.so)
undefined symbol: _ZN11paddle2onnx12IsExportableEPKviS1_iibbbbbPNS_8CustomOpEiPKc (./libinfer-jna.so)
undefined symbol: OrtGetApiBase, version VERS_1.11.1 (./libinfer-jna.so)
undefined symbol: dnnl_sum_primitive_desc_create (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_permute_axes (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_iterator_fetch (./libinfer-jna.so)
undefined symbol: dnnl_resampling_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_create (./libinfer-jna.so)
undefined symbol: dnnl_shuffle_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_len (./libinfer-jna.so)
undefined symbol: dnnl_gru_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_dilated_deconvolution_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_get_size (./libinfer-jna.so)
undefined symbol: dnnl_pooling_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_primitive_create (./libinfer-jna.so)
undefined symbol: dnnl_reorder_primitive_desc_create (./libinfer-jna.so)
undefined symbol: GOMP_parallel, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_stream_destroy (./libinfer-jna.so)
undefined symbol: dnnl_stream_create (./libinfer-jna.so)
undefined symbol: _ZN11paddle2onnx6ExportEPKviS1_iPPcPiibbbbbPNS_8CustomOpEiPKc (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_create (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_set_rnn_data_qparams (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_equal (./libinfer-jna.so)
undefined symbol: dnnl_primitive_get_primitive_desc (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_init_by_tag (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_iterator_destroy (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_set_rnn_weights_qparams (./libinfer-jna.so)
undefined symbol: dnnl_softmax_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_get_data_handle (./libinfer-jna.so)
undefined symbol: GOMP_atomic_end, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_prelu_backward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_memory_get_engine (./libinfer-jna.so)
undefined symbol: _ZN11paddle2onnx12IsExportableEPKcS1_ibbbbbPNS_8CustomOpEiS1_ (./libinfer-jna.so)
undefined symbol: dnnl_batch_normalization_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_eltwise_forward_desc_init (./libinfer-jna.so)
undefined symbol: dnnl_primitive_desc_iterator_create (./libinfer-jna.so)
undefined symbol: omp_get_max_threads, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_primitive_attr_set_post_ops (./libinfer-jna.so)
undefined symbol: GOMP_atomic_start, version VERSION (./libinfer-jna.so)
undefined symbol: dnnl_post_ops_append_binary (./libinfer-jna.so)
undefined symbol: dnnl_memory_desc_init_submemory (./libinfer-jna.so)
undefined symbol: _ZN11paddle2onnx6ExportEPKcS1_PPcPiibbbbbPNS_8CustomOpEiS1_ (./libinfer-jna.so)
使用的名称不对, 通过nm和c++filt来定位方法
nm找到undefined symbol名称
c++filt可以还原C++ symbol
$ nm libinfer-jna.so | grep _ZN11paddle2onnx12IsExportableEPKcS1_ibbbbbPNS_8CustomOpEiS1_
U _ZN11paddle2onnx12IsExportableEPKcS1_ibbbbbPNS_8CustomOpEiS1_
$ c++filt _ZN11paddle2onnx12IsExportableEPKcS1_ibbbbbPNS_8CustomOpEiS1_
paddle2onnx::IsExportable(char const*, char const*, int, bool, bool, bool, bool, bool, paddle2onnx::CustomOp*, int, char const*)
通过nm查看的,如果状态为U,且没有地址的,就是undefined symbol
需要注意的是,不是所有的undefined symbol都影响程序的运行。
原则是遇到问题,解决问题,没遇到问题,也没必要把所有的undefined symbol都消除。
网友评论