Libraries not accessible for “classloader-namespace”, when loading DL4J model using restoreMultiLayerNetwork()

↘锁芯ラ 提交于 2020-02-02 12:09:47

问题


I cannot find out how to get rid of / solve the below errors, that occur when loading a Neural Network model using the DL4J method restoreMultiLayerNetwork using Android API >= 24:

The errors occur when the following line within the method restoreMultiLayerNetwork is called:

params = Nd4j.read(ins2);

with

InputStream ins2 = getResources().openRawResource(getResources().getIdentifier("coefficients", "raw", getPackageName()));

and

"coefficients.bin" is the coefficients file, created by the below method from DL4J, when exporting a DL4J neural network:

ModelSerializer.writeModel(model, locationToSave, saveUpdater);

Errors: Libraries not accessible for "classloader-namespace"

E/linker: library "/vendor/lib64/libcutils.so" ("/vendor/lib64/libcutils.so") needed or dlopened by "/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64:/data/app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_8_apk.apk!

library "/vendor/lib64/libutils.so" ("/vendor/lib64/libutils.so") needed or dlopened by "/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64:/data/app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_8_apk.apk!/l

W/linker: library "/system/lib64/libbinder.so" ("/system/lib64/libbinder.so") needed or dlopened by "/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.

E/linker: library "/vendor/lib64/libnativeloader.so" ("/vendor/lib64/libnativeloader.so") needed or dlopened by "/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64:/data/app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slic

W/linker: library "/system/lib64/libandroid_runtime.so" ("/system/lib64/libandroid_runtime.so") needed or dlopened by "/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.

Version of Android: API >= 24

Extract from build.gradle, where ND4J dependencies are set:

    android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.arai.arai"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath false
        }
        }


    buildTypes {
        release {
            minifyEnabled true
        shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildscript {
    configurations.all {
        resolutionStrategy {
            force 'net.sf.proguard:proguard-gradle:5.3.2'
        }
    }
    }

     packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/INDEX.LIST'

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:design:27.1.0'

    compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-beta2') {
    exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
    }      
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2'
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm64"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"

    implementation 'com.google.code.gson:gson:2.8.2'
    annotationProcessor 'org.projectlombok:lombok:1.16.16'

    implementation 'com.google.code.findbugs:annotations:3.0.1', {
        exclude module: 'jsr305'
        exclude module: 'jcip-annotations'
    }

    //This corrects for a junit version conflict.
    configurations.all {
        resolutionStrategy.force 'junit:junit:4.12'
    }

}}

来源:https://stackoverflow.com/questions/52515309/libraries-not-accessible-for-classloader-namespace-when-loading-dl4j-model-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!