# How to specify version for dependencies so that each one is compatible and stays within a size limit?

I am trying to deploy a web app to Heroku. The free tier is limited to 500 MB.

I am using my resnet34 model as a .pkl file.

I create model with it using the fastai library.

This project requires torch and torchvision as dependencies.

So, I specify torchvision version as 0.2.2 and specify the wheel for torch for v1.1.0 in the requirements.txt file. Now, this gives rise to other problems.

For example, I got this error message from Heroku build log-

ERROR: torchvision 0.2.2 has requirement tqdm==4.19.9, but you'll have tqdm 4.48.0 which is incompatible.

But if I specify tqdm's version to 4.19.9, some library called spacey becomes incompatible and the app fails. If I install more recent version of torchvision, the app size will exceed permitted limits.

How do I get around this problem? How do I find out which dependency versions are compatible with each other, and the total size doesn't exceed 500 MB? Is there an easy way to do that?

• avoid fastai as it has many dependencies; you are good to use the raw libs due to space restrictions! Aug 1 '20 at 19:08
• @Aditya , using fastai makes the source code small and it is easy to use. That's why I use it. And I cannot really use the latest versions, because they exceed permitted limit. Aug 2 '20 at 5:48
• Yep! I know what fastAI is but as I said, the requirements are little high for it. Why don't you try a smaller model? Aug 2 '20 at 6:18
• @Aditya Model is not a bottleneck. It's less than 90 MB. Aug 2 '20 at 6:28
• Cool! Can you attach a sample as an answer as well? Aug 13 '20 at 6:27

Till now, what I have learned is that it is a trial and error process.

And the best solution is to look for projects that have already done this using a working combination of libraries.

I used this requirements.txt file, which works fine:

gunicorn