chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
833 stars 131 forks source link

App shutdown issue #731

Closed NeighborhoodCoding closed 2 years ago

NeighborhoodCoding commented 2 years ago

Chaquopy version

10.0.1

Devices or emulators where the issue happens

Samsung A80

Relevant parts of your code

All of the part in python, especially, pytorch's forward API

Describe your issue

Hi, I'm a Deep learning engineer. I'm using Chaquopy for the AI model's prediction and it works well. But When I import very deep CNN models and predict over and over and over again, suddenly the app is forcibly shut down.

I don't know why, but the very frequent dying part is the python code line that is using PyTorch's forward API. It is very rare because it only happens when using very many deep CNN models... Now I'm using a lightened model instead of an unnecessarily deep model and make predictions with some sampled input instead of all of the inputs, so the app worked well now.

I think the OS took protective measures because of the hot temperature or Chaquopy has some logic that prevents to use too much memory because of memory issues...?

Although it is not a critical issue, for those who may face a similar issue in the future, I want to ask some questions. Are there may some helpful ways to lighten some load of Chaquopy? I'm thinking adding some "time.sleep()" in python code may help to keep the device in the good memory status Or There is more thing can I do? Thank you.

mhsmith commented 2 years ago

I don't think overheating would cause the OS to shut down an individual app. Running out of memory is more likely.

But rather than guess, your first step should be to look in the Logcat for the messages around the time of the crash. This may point you directly to the source of the problem, but if you need any more help, post the messages here and I'll have a look at them.