pytorch / android-demo-app

PyTorch android examples of usage in applications
1.47k stars 606 forks source link

java.lang.IllegalStateException: Cannot re-initialize NativeLoader. #143

Open mustansarsaeed opened 3 years ago

mustansarsaeed commented 3 years ago

Hi, I am trying to load module in the mobile app but I get the following error:

W/System.err: java.lang.IllegalStateException: Cannot re-initialize NativeLoader.
W/System.err:     at com.facebook.soloader.nativeloader.NativeLoader.init(NativeLoader.java:54)
W/System.err:     at org.pytorch.Module.load(Module.java:21)
W/System.err:     at org.openmined.syft.execution.Plan.loadScriptModule(Plan.kt:55)
W/System.err:     at org.openmined.syft.domain.JobRepository$processPlans$2$1.subscribe(JobRepository.kt:186)
W/System.err:     at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:84)
W/System.err:     at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback$FlatMapSingleObserver.onSuccess(SingleFlatMap.java:111)
W/System.err:     at io.reactivex.internal.operators.single.SingleJust.subscribeActual(SingleJust.java:30)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:84)
W/System.err:     at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
W/System.err:     at io.reactivex.internal.operators.observable.ObservableSingleSingle$SingleElementObserver.onComplete(ObservableSingleSingle.java:109)
W/System.err:     at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:51)
W/System.err:     at io.reactivex.Observable.subscribe(Observable.java:12267)
W/System.err:     at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual(SingleFlatMap.java:36)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual(SingleFlatMap.java:36)
W/System.err:     at io.reactivex.Single.subscribe(Single.java:3603)
W/System.err:     at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
W/System.err:     at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err:     at java.lang.Thread.run(Thread.java:764)
E/Syft: Cannot re-initialize NativeLoader.

Module.kt already have the checks for already initialized component as follows:

public static Module load(final String modelPath) {
    if (!NativeLoader.isInitialized()) {
      NativeLoader.init(new SystemDelegate());
    }
    return new Module(new NativePeer(modelPath));
  }

Why I am getting the exception. Can anyone please provide any pointer. Thanks.