pytorch / android-demo-app

PyTorch android examples of usage in applications
1.45k stars 596 forks source link

D2Go app crashes on startup #243

Open Cubemaster110 opened 2 years ago

Cubemaster110 commented 2 years ago

I'm not terribly experienced with Android studio, so I'm not sure if I set something up wrong, but every time I try to launch the D2Go app, either on an emulator or on an actual device, the app crashes immediately. I've used Logcat to try to get an idea of what the problem is, and i get the following error:

2022-04-06 11:11:56.750 32618-32618/? I/objectdetectio: Late-enabling -Xcheck:jni 2022-04-06 11:11:56.769 32618-32618/? E/USNET: USNET: appName: org.pytorch.demo.objectdetection 2022-04-06 11:11:56.771 32618-32618/? D/ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument 2022-04-06 11:11:56.773 32618-32618/? D/ActivityThread: setConscryptValidator 2022-04-06 11:11:56.774 32618-32618/? D/ActivityThread: setConscryptValidator - put 2022-04-06 11:11:56.801 32618-32618/? V/studio.deploy: Startup agent attached to VM 2022-04-06 11:11:56.801 32618-32618/? V/studio.deploy: No existing instrumentation found. Loading instrumentation from instruments-88564b4d.jar 2022-04-06 11:11:56.802 32618-32618/? W/objectdetectio: DexFile /data/data/org.pytorch.demo.objectdetection/code_cache/.studio/instruments-88564b4d.jar is in boot class path but is not in a known location 2022-04-06 11:11:56.803 32618-32618/? V/studio.deploy: Applying transforms with cached classes 2022-04-06 11:11:56.810 32618-32618/? W/objectdetectio: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2022-04-06 11:11:56.810 32618-32618/? W/objectdetectio: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2022-04-06 11:11:56.813 32618-32618/? D/ActivityThread: handleBindApplication()++ app=org.pytorch.demo.objectdetection 2022-04-06 11:11:56.813 32618-32618/? D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10368; state: DISABLED 2022-04-06 11:11:56.820 32618-32618/? W/ActivityThread: Application org.pytorch.demo.objectdetection is waiting for the debugger on port 8100... 2022-04-06 11:11:56.820 32618-32618/? I/System.out: Sending WAIT chunk 2022-04-06 11:11:57.821 32618-32618/? I/System.out: Debugger has connected 2022-04-06 11:11:57.822 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:58.022 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:58.222 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:58.423 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:58.623 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:58.775 32618-32632/? W/System: A resource failed to call close. 2022-04-06 11:11:58.823 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:59.024 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:59.224 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:59.424 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:59.625 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:11:59.825 32618-32618/? I/System.out: waiting for debugger to settle... 2022-04-06 11:12:00.027 32618-32618/? I/System.out: debugger has settled (1450) 2022-04-06 11:12:00.030 32618-32618/? W/ActivityThread: Slow operation: 3217ms so far, now at handleBindApplication: Before HardwareRenderer 2022-04-06 11:12:00.060 32618-32618/? W/ActivityThread: Slow operation: 3247ms so far, now at handleBindApplication: After HardwareRenderer 2022-04-06 11:12:00.170 32618-32618/? V/GraphicsEnvironment: ANGLE Developer option for 'org.pytorch.demo.objectdetection' set to: 'default' 2022-04-06 11:12:00.170 32618-32618/? V/GraphicsEnvironment: App is not on the allowlist for updatable production driver. 2022-04-06 11:12:00.192 32618-32618/? D/LoadedApk: LoadedApk::makeApplication() appContext.mOpPackageName=org.pytorch.demo.objectdetection appContext.mBasePackageName=org.pytorch.demo.objectdetection 2022-04-06 11:12:00.192 32618-32618/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default 2022-04-06 11:12:00.329 32618-32618/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default 2022-04-06 11:12:00.331 32618-32618/? D/Camera2Initializer: CameraX initializing with Camera2 ... 2022-04-06 11:12:00.338 32618-32618/? I/CameraManagerGlobal: Connecting to camera service 2022-04-06 11:12:00.341 32618-32618/? D/VendorTagDescriptor: addVendorDescriptor: vendor tag id 14172875900359437128 added 2022-04-06 11:12:00.353 32618-32635/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.android.settings API Level 1 2022-04-06 11:12:00.361 32618-32635/? I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.android.smartface API Level 2 2022-04-06 11:12:00.368 32618-32635/? I/CameraManagerGlobal: Camera 2 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.375 32618-32635/? I/CameraManagerGlobal: Camera 20 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.sec.android.app.camera API Level 2 2022-04-06 11:12:00.378 32618-32635/? I/CameraManagerGlobal: Camera 21 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.381 32618-32635/? I/CameraManagerGlobal: Camera 23 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.385 32618-32635/? I/CameraManagerGlobal: Camera 3 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.388 32618-32635/? I/CameraManagerGlobal: Camera 4 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.391 32618-32635/? I/CameraManagerGlobal: Camera 40 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.394 32618-32635/? I/CameraManagerGlobal: Camera 41 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.397 32618-32635/? I/CameraManagerGlobal: Camera 50 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.400 32618-32635/? I/CameraManagerGlobal: Camera 52 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.402 32618-32635/? I/CameraManagerGlobal: Camera 80 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.404 32618-32635/? I/CameraManagerGlobal: Camera 91 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2 2022-04-06 11:12:00.411 32618-32618/? D/CameraRepository: Added camera: 0 2022-04-06 11:12:00.422 32618-32618/? D/CameraRepository: Added camera: 1 2022-04-06 11:12:00.425 32618-32618/? D/CameraRepository: Added camera: 2 2022-04-06 11:12:00.429 32618-32618/? D/CameraRepository: Added camera: 3 2022-04-06 11:12:00.429 32618-32657/? D/UseCaseAttachState: Active and online use case: [] for camera: 0 2022-04-06 11:12:00.432 32618-32618/? D/CameraRepository: Added camera: 4 2022-04-06 11:12:00.437 32618-32657/? D/UseCaseAttachState: Active and online use case: [] for camera: 1 2022-04-06 11:12:00.438 32618-32618/? D/ActivityThread: handleBindApplication() -- 2022-04-06 11:12:00.446 32618-32657/? D/UseCaseAttachState: Active and online use case: [] for camera: 2 2022-04-06 11:12:00.455 32618-32657/? D/UseCaseAttachState: Active and online use case: [] for camera: 3 2022-04-06 11:12:00.460 32618-32657/? D/UseCaseAttachState: Active and online use case: [] for camera: 4 2022-04-06 11:12:00.468 32618-32658/? D/OpenGLRenderer: RenderThread::requireGlContext() 2022-04-06 11:12:00.468 32618-32658/? I/AdrenoGLES-0: QUALCOMM build : 3dad7f8ed7, I593c16c433 Build Date : 10/01/21 OpenGL ES Shader Compiler Version: EV031.32.02.02 Local Branch : Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.9.1.R1.11.00.00.604.073 Remote Branch : NONE Reconstruct Branch : NOTHING 2022-04-06 11:12:00.468 32618-32658/? I/AdrenoGLES-0: Build Config : S P 10.0.7 AArch64 2022-04-06 11:12:00.468 32618-32658/? I/AdrenoGLES-0: Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so 2022-04-06 11:12:00.472 32618-32658/? I/AdrenoGLES-0: PFP: 0x016ee190, ME: 0x00000000 2022-04-06 11:12:00.476 32618-32658/? D/OpenGLRenderer: RenderThread::setGrContext() 2022-04-06 11:12:00.683 32618-32618/? I/DecorView: [INFO] isPopOver=false, config=true 2022-04-06 11:12:00.683 32618-32618/? I/DecorView: updateCaptionType >> DecorView@eaa443c[], isFloating=false, isApplication=true, hasWindowControllerCallback=true, hasWindowDecorCaption=false 2022-04-06 11:12:00.683 32618-32618/? D/DecorView: setCaptionType = 0, this = DecorView@eaa443c[] 2022-04-06 11:12:00.701 32618-32618/? I/DecorView: getCurrentDensityDpi: from real metrics. densityDpi=420 msg=resources_loaded 2022-04-06 11:12:00.766 32618-32618/? W/objectdetectio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed) 2022-04-06 11:12:00.767 32618-32618/? W/objectdetectio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed) 2022-04-06 11:12:01.754 32618-32618/? D/AndroidRuntime: Shutting down VM 2022-04-06 11:12:01.765 32618-32618/? E/AndroidRuntime: FATAL EXCEPTION: main Process: org.pytorch.demo.objectdetection, PID: 32618 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: Unknown builtin op: aten::_upsample_nearest_exact1d. Could not find any similar ops to aten::_upsample_nearest_exact1d. This op may not exist or may not be currently supported in TorchScript. : File "C:\Users\John\anaconda3\envs\d2go\lib\site-packages\torch\nn\functional.py", line 3896

    if input.dim() == 3 and mode == "nearest-exact":
        return torch._C._nn._upsample_nearest_exact1d(input, output_size, scale_factors)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    if input.dim() == 4 and mode == "nearest-exact":
        return torch._C._nn._upsample_nearest_exact2d(input, output_size, scale_factors)
Serialized   File "code/__torch__/torch/nn/functional/___torch_mangle_629.py", line 177
          _54 = False
        if _54:
          _57 = torch._upsample_nearest_exact1d(input, output_size3, scale_factors3)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
          _56 = _57
        else:

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4031)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4197)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2434)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8633)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
 Caused by: com.facebook.jni.CppException: 
Unknown builtin op: aten::_upsample_nearest_exact1d.
Could not find any similar ops to aten::_upsample_nearest_exact1d. This op may not exist or may not be currently supported in TorchScript.
:
  File "C:\Users\John\anaconda3\envs\d2go\lib\site-packages\torch\nn\functional.py", line 3896

    if input.dim() == 3 and mode == "nearest-exact":
        return torch._C._nn._upsample_nearest_exact1d(input, output_size, scale_factors)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    if input.dim() == 4 and mode == "nearest-exact":
        return torch._C._nn._upsample_nearest_exact2d(input, output_size, scale_factors)
Serialized   File "code/__torch__/torch/nn/functional/___torch_mangle_629.py", line 177
          _54 = False
        if _54:
          _57 = torch._upsample_nearest_exact1d(input, output_size3, scale_factors3)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
          _56 = _57
        else:

    at org.pytorch.NativePeer.initHybridAndroidAsset(Native Method)
    at org.pytorch.NativePeer.<init>(NativePeer.java:34)
    at org.pytorch.PyTorchAndroid.loadModuleFromAsset(PyTorchAndroid.java:31)
    at org.pytorch.demo.objectdetection.MainActivity.onCreate(MainActivity.java:177)
    at android.app.Activity.performCreate(Activity.java:8282)
    at android.app.Activity.performCreate(Activity.java:8262)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4005)
        ... 12 more

2022-04-06 11:12:01.814 32618-32618/? I/Process: Sending signal. PID: 32618 SIG: 9

I'm not sure exactly what the issues is here, or how I can resolve it. Any help would be appreciated.

jwwinship commented 2 years ago

I still have no idea what the issue really was, but I was running into a lot of issues when trying to install the project in an Anaconda environment, and building the model myself. When I simply cloned the project and ran it through android studio, I ran into no issues.

nh9k commented 2 years ago

@Cubemaster110 @jwwinship Did you solve your problem? I am facing the same issue.

wonwoolee commented 1 year ago

The same error occurs on my android app, which is using another network model. Any solutions to this issue?