How to install opencv with serverless function [python]?

Adding a python dependency to a DigitalOcean function seems straight-forward:

It appears to work when I install numpy and Pillow:


However, I’m having trouble when trying to add opencv:


When attempting to deploy from the CLI I get this error:

Error: While deploying action ‘test/crop’ (running remote build): The action exhausted its memory and was aborted.

Any tips?

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
January 20, 2023

Hi there,

Your function seems to be running out of memory according to this part of the output that you’ve shared:

The action exhausted its memory and was aborted.

I’ve just answered a similar question on how to increase your function memory limit, I would recommend following the steps here:

Let me know if you have any questions!



Try DigitalOcean for free

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

Sign up