Question

Tensorflow, torch memory not enough error.

As following some tutorials on web app with flask. I made a trained model flask app with Tensorflow and torch, however I have tried many times and different lite version of them both they will not get install. The code I have is here in the GitHub. I have trained model in pickle stored in spaces. However I have not been able to deploy with even large app RAM.

Thank in advance for the help.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 2, 2023

Hi there,

Indeed, apps that use libraries like TensorFlow and PyTorch have high memory requirements.

What I could suggest is:

  • You can start by trying to upgrade your server to a larger instance with more memory.
  • Add a SWAP file so that you could have some extra buffer

If this still does not help, there are a few other things that you could try like:

  1. Find lightweight versions or alternatives to these libraries. For example, consider using TensorFlow Lite or PyTorch Mobile, which are designed to be used on devices with less computational power.

  2. You can try reducing the size of your model. Here are some tips on how to do that:

    https://www.tensorflow.org/lite/performance/model_optimization

Alternatively, consider using a different framework like Streamlit that is built to handle ML and DL models in a memory-efficient way.

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel