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

find a way to optimize AI loading times #166

Open
evilsocket opened this issue Oct 5, 2019 · 6 comments
Open

find a way to optimize AI loading times #166

evilsocket opened this issue Oct 5, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed idea things to research and experiment with

Comments

@evilsocket
Copy link
Owner

TensorFlow takes minutes to import on a Raspberry Pi Zero W and that's probably because of the huge .so file with native primitives it has to load, among other things. Given the nature of the project, that stuff is imported only once, so caching it in memory wouldn't speed things up. Switching frameworks is not feasible, unless we have the same exact features (unlikely given that stable-baselines is TF based). For instance, there's no stable-baselines port for TF-lite.

@evilsocket evilsocket added enhancement New feature or request help wanted Extra attention is needed idea things to research and experiment with labels Oct 5, 2019
@evilsocket evilsocket self-assigned this Oct 5, 2019
@evilsocket
Copy link
Owner Author

@caquino this is a nice hacktoberfest entry

@caquino
Copy link
Contributor

caquino commented Oct 8, 2019

👍

@araffin
Copy link

araffin commented Oct 10, 2019

Switching frameworks is not feasible, unless we have the same exact features (unlikely given that stable-baselines is TF based).

I think the two main things that takes time:

  • importing tensorflow (I don't know how it is for tf 2.0 but the support is planned: Tensorflow 2.0 support? hill-a/stable-baselines#366), there will be also a pytorch version in the future (only internal for now)
  • creating and compiling the network: in your case, you are creating a lstm so it takes even more time. I don't know how much time-dependency there is in this task but I would recommend you to check out observations stacking (cf VecFrameStack) + using a MLP instead of using a recurrent net. I would also recommend you to give PPO2 a try (with clip_vf_range=None) it performs usually better than A2C (anyway, you will need to tune some params, you can take a look at the rl zoo where hyperparameter optimization is included)

EDIT: Regarding issue #49, CMA-ES (which has a nice python package) is usually a good start

@evilsocket
Copy link
Owner Author

@araffin thanks for your feedback!

  • Yep TF alone takes a lot, mostly due to a 130MB .so file with all the native code.
  • The LSTM seemed to perform way better than MLP alone, it tends to generate useful policies way faster, that is why the choice. As long as I know, if I don't use VecFrameStack an exception is thrown. Will check PPO2, thanks a lot!

For #49 I already have my own implementation, but thanks :D

@d3sm0
Copy link

d3sm0 commented Oct 28, 2019

Importing stable baseline, all old tensorflow (works on v1 not v2) which loads all the tf graph in memory the first time, instead of compiling at run time, makes way to heavy.

Maybe one can rewrite a2c tuned for this application and use (not sure if you are already doing this) a compiled version for rasberry. This should reduce loading time quite a bit.

As a side: LSTM is computationally heavy to run (complexity is on the size of the features) and it make sense if you have long time dependencies in your time-series. Is this the case? One can try to use 1d convolution (complexity is on number of samples) which are more suitable for time-series kind of signal.

@evilsocket
Copy link
Owner Author

As a side: LSTM is computationally heavy to run (complexity is on the size of the features) and it make sense if you have long time dependencies in your time-series. Is this the case?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed idea things to research and experiment with
Projects
None yet
Development

No branches or pull requests

4 participants