djangoとpytorchを用いた画像認識Webアプリを作成し、herokuへ git pushしたらエラーになり失敗。pushできない
Compiled slug size: xxxM is too large (max is 500M).
容量オーバーのようです。モデルは50MB程度、
何が大きいのか確認すると、
Downloading torch-1.11.0-cp39-cp39-manylinux1_x86_64.whl (750.6 MB)
Pytorchが750MBもある。
Pytorchはgpu用がサイズが大きく、cpu用を指定するとサイズ削減できるとのことで
requirements.txt の Pytorch部分を修正する。
変更前
requirements.txt
torch==1.11.0
変更後
requirements.txt
-f https://download.pytorch.org/whl/torch_stable.html
torch==1.11.0+cpu
170MBになり、問題なくherokuにgit pushもできました。
Downloading https://download.pytorch.org/whl/cpu/torch-1.11.0%2Bcpu-cp39-cp39-linux_x86_64.whl (169.2 MB)