So, on heroku i am only interested in deploying the app, similar to what Jeremy showed with binder. so i have trained the model, exported to .pkl file. now i want to deploy the app to heroku using streamlit. the issue i have is that heroku limits build size to 500MB. When i put fastai2 in requirements.txt, heroku will build it with pip install fastai2. Which installs everyting fastai2 has (nlp, tabular, collabe, vision) and all dependencies which is more than 500MB. I found the way to install torch for cpu only which was just below the limit, but when i uploaded export.pkl file it went up above limit again
What i want to find out - if it’s possible to do something like pip install --no-deps on heroku, but so far i haven’t managed to find that, or any other method really to install only required bits from fastai2 on heroku platform.
This is re-post from the beginner forums, but as this wasn’t discussed in the lecture i think it’s better suited for the non-beginner
Try saving the PyTorch model file (ex: learn.pth), and performing inference with PyTorch (CPU version). Also, some models (like ResNet50) will still likely not fit under the 500 MB requirement. Try training with smaller models. Some of the smaller models included in torchvision include SqueezeNets and MobileNetV2.
EfficientNet’s are a good alternative too for smaller but powerful models, last week I was training an EfficientNet b5 that was 466mb when exported, it should outperform a vanilla ResNet50.
-----> Deleting 4 files matching .slugignore patterns.
-----> Python app detected
cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory
-----> Installing python-3.8.2
-----> Installing pip
-----> Installing dependencies with Pipenv 2018.5.18…
Installing -e git+https://github.com/fastai/fastai2@4ac2d8913a5094fb15489f4b80296b9429330b8e#egg=fastai2…
Obtaining fastai2 from git+https://github.com/fastai/fastai2@4ac2d8913a5094fb15489f4b80296b9429330b8e#egg=fastai2
Cloning https://github.com/fastai/fastai2 (to 4ac2d8913a5094fb15489f4b80296b9429330b8e) to ./src/fastai2
Collecting fastcore (from fastai2)
Downloading https://files.pythonhosted.org/packages/3b/b5/aed836ce5b16ea1088a5d1a41d400bc051abf90bbef58bb74d8fd01a76af/fastcore-0.1.16-py3-none-any.whl
Collecting torch<1.4.0,>=1.2.0 (from fastai2)
Error: An error occurred while installing -e git+https://github.com/fastai/fastai2@4ac2d8913a5094fb15489f4b80296b9429330b8e#egg=fastai2!
Could not find a tag or branch '4ac2d8913a5094fb15489f4b80296b9429330b8e', assuming commit.
Could not find a version that satisfies the requirement torch<1.4.0,>=1.2.0 (from fastai2) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0)
No matching distribution found for torch<1.4.0,>=1.2.0 (from fastai2)
You are using pip version 9.0.2, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
! Push rejected, failed to compile Python app.
! Push failed
nut sure if i need torchvision though, can experiment with it
i wanted to install fastai2 but without all the dependencies i don’t need for CV problem, like spacy, pandas, etc. but couldn’t find a way to do it. i wrote to heroku support but they replied that they don’t know --no-deps but insted they gave me more space for this container 650MB isntead of 500MB and it worked.