Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing torch and torchvision #579

Closed
Deep55033 opened this issue Jan 16, 2022 · 10 comments
Closed

Error importing torch and torchvision #579

Deep55033 opened this issue Jan 16, 2022 · 10 comments

Comments

@Deep55033
Copy link

Chaquopy version

10.0.1

Devices or emulators where the issue happens

huawei p40

Relevant parts of your code

import numpy as np
import cv2
import torch
import tflite_runtime.interpreter as tflite
from os.path import dirname, join
import torchvision
import time

Describe your issue

Program crashes when importing torch and torchvision, this is the log

2022-01-16 11:19:35.218 22792-22792/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2022-01-16 11:19:35.218 22792-22792/? A/DEBUG: Build fingerprint: 'HUAWEI/ANA-AN00/HWANA:10/HUAWEIANA-AN00/102.0.0.218C00:user/release-keys'
2022-01-16 11:19:35.218 22792-22792/? A/DEBUG: Revision: '0'
2022-01-16 11:19:35.218 22792-22792/? A/DEBUG: ABI: 'arm64'
2022-01-16 11:19:35.218 1071-1113/? D/AwareLog: iawared: WorkingsetProcessCommand subCmd = 351, userId=10787, pid=22094, car.bkrckj_logo.com.car2019/car.bkrc.com.car2018.FirstActivity
2022-01-16 11:19:35.218 1071-1113/? D/AwareLog: iawared: WorkingsetPause car.bkrckj_logo.com.car2019/car.bkrc.com.car2018.FirstActivity
2022-01-16 11:19:35.220 22792-22792/? A/DEBUG: SYSVMTYPE: Maple
    APPVMTYPE: Art
2022-01-16 11:19:35.220 22792-22792/? A/DEBUG: Timestamp: 2022-01-16 11:19:35+0800
2022-01-16 11:19:35.220 22792-22792/? A/DEBUG: pid: 22094, tid: 22783, name: pool-2-thread-1  >>> car.bkrckj_logo.com.car2019 <<<
2022-01-16 11:19:35.220 22792-22792/? A/DEBUG: uid: 10787
2022-01-16 11:19:35.220 22792-22792/? A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x0  0000000000000000  x1  00000000000058ff  x2  0000000000000006  x3  0000007c06fdd630
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x4  fefeffb6e68c9b0a  x5  fefeffb6e68c9b0a  x6  fefeffb6e68c9b0a  x7  7f7f7fffffffff7f
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x8  00000000000000f0  x9  2a37443975067369  x10 0000000000000001  x11 0000000000000000
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x12 fffffff0fffffbdf  x13 ffffffffffffffff  x14 0000000000000000  x15 0060cfc05f9f072d
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x16 0000007c9b9eca08  x17 0000007c9b9cc7c0  x18 0000007b6a9620e8  x19 000000000000564e
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x20 00000000000058ff  x21 00000000ffffffff  x22 0000007b64bf4f20  x23 0000000000000004
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x24 0000000000000000  x25 0000000000001002  x26 0000007b6820b987  x27 0000007b6941d360
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     x28 0000007b6941d320  x29 0000007c06fdd6d0
2022-01-16 11:19:35.221 22792-22792/? A/DEBUG:     sp  0000007c06fdd610  lr  0000007c9b981640  pc  0000007c9b98166c
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG: backtrace:
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:     NOTE: Function names and BuildId information is missing for some frames due
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:     NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:     NOTE: found under the lib/ directory are readable.
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #00 pc 000000000007066c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: b91c775ccc9b0556e91bc575a2511cd0)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #01 pc 00000000000b2ba0  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libc++_shared.so (offset 0xfc84000) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #02 pc 00000000000aec8c  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libc++_shared.so (offset 0xfc84000) (__gxx_personality_v0+348) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #03 pc 000000000030621c  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libpaddle_light_api_shared.so (offset 0xfd63000)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #04 pc 0000000000306540  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libpaddle_light_api_shared.so (offset 0xfd63000)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #05 pc 00000000002d6bb0  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libpaddle_light_api_shared.so (offset 0xfd63000) (__cxa_throw+112)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #06 pc 000000000008eaec  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libc++_shared.so (offset 0xfc84000) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #07 pc 00000000000699d8  /data/app/car.bkrckj_logo.com.car2019-S7RywyMT_p7deNj6i3-JJA==/base.apk!libc++_shared.so (offset 0xfc84000) (std::__ndk1::locale::use_facet(std::__ndk1::locale::id&) const+176) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #08 pc 0000000000772e80  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #09 pc 00000000008d6390  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #10 pc 00000000008d58d4  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #11 pc 0000000000787594  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #12 pc 000000000078a9a0  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #13 pc 00000000005f4ba4  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libtorch_cpu.so
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #14 pc 0000000000051ba8  /apex/com.android.runtime/bin/linker64 (__dl__ZL10call_arrayIPFviPPcS1_EEvPKcPT_mbS5_+276) (BuildId: f405d2f91763b4996966c787daaa93ef)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #15 pc 0000000000051dc4  /apex/com.android.runtime/bin/linker64 (__dl__ZN6soinfo17call_constructorsEv+376) (BuildId: f405d2f91763b4996966c787daaa93ef)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #16 pc 000000000003d9a0  /apex/com.android.runtime/bin/linker64 (__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv+2428) (BuildId: f405d2f91763b4996966c787daaa93ef)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #17 pc 0000000000039160  /apex/com.android.runtime/bin/linker64 (__loader_dlopen+68) (BuildId: f405d2f91763b4996966c787daaa93ef)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #18 pc 0000000000001020  /apex/com.android.runtime/lib64/bionic/libdl.so (dlopen+12) (BuildId: ee5a54c32874d345e4d2f02a4cbace8a)
2022-01-16 11:19:35.222 22792-22792/? A/DEBUG:       #19 pc 0000000000011ff0  /data/data/car.bkrckj_logo.com.car2019/files/chaquopy/bootstrap-native/arm64-v8a/_ctypes.so
@mhsmith
Copy link
Member

mhsmith commented Jan 17, 2022

Are you sure the crash happens during the import, and not some other piece of code? You can check by adding print lines between the import lines, and seeing which messages appear in the Logcat before the crash happens.

If it is caused by the import lines, which line is it specifically, and what is the minimal set of imports that reproduces the problem?

I assume libpaddle_light_api_shared is something you've added to the app yourself? Can you explain how it relates to torch, and can you think of any reason why the two libraries might conflict?

@Deep55033
Copy link
Author

libpaddle_light_api_shared is not added to the program by myself, this problem will occur when importing either torch or torchvision

@Deep55033
Copy link
Author

I'm sure the crash happens when importing torch and torchvision

@mhsmith
Copy link
Member

mhsmith commented Jan 19, 2022

this problem will occur when importing either torch or torchvision

Does the problem still happen even if there's nothing in the Python file except import torch, and you don't execute any other Python code?

libpaddle_light_api_shared is not added to the program by myself

Well, it's not included in Chaquopy or any of the packages we provide, so you must be adding it somehow. From this page, it appears to be another machine learning framework, so it may be interfering with torch in some way.

Try removing it and see if that makes the problem disappear. If it still crashes but gives a different stack trace, please post that.

@Deep55033
Copy link
Author

Well, it is indeed the paddle's problem, thanks.

@cyz6668
Copy link

cyz6668 commented Jul 3, 2024

@Deep55033 What is the problem with paddle , I have the same problem with RKNN tools (#1195). Can you give me a tip?

@Deep55033
Copy link
Author

@cyz6668 I don't know either. When I removed the paddle from the project, the problem was solved.

@cyz6668
Copy link

cyz6668 commented Jul 3, 2024

@Deep55033 what if I consisted on using the paddle or rk3588...

@Deep55033
Copy link
Author

Deep55033 commented Jul 6, 2024

@cyz6668 Could you tell me what you need to do with chaquopy? If you just need to infer the model, I would recommend using tensorflow lite.

@cyz6668
Copy link

cyz6668 commented Jul 8, 2024

@Deep55033 I need to infer my model on rockship RKNN3588 and develop our deployment SDK using Android. And we have python scripts developed before and we want them to deal with the results from the model deploment. So we need chaquopy to import these scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants