実現したいこと
pythonで作成したゲームをHerokuにデプロイしようと考えています。
しかし、デプロイしようとすると、
Compiled slug size: 2.8G is too large (max is 500M).
というメッセージが出て失敗します。
本来のアプリのサイズよりも明らかに大きくなってしまっています。
そのため、 slug sizeを500M以下にしたいのですがそれができません。
発生している問題・分からないこと
そこまでサイズの大きいファイルを大量に作った訳ではないので、おそらくパッケージ関連の問題だと思います。機械学習を使っているので、それ関連のパッケージのサイズが大きいのではないかと考えています。そのためrequirements.txtの内容を見てサイズの大きいものはないかなどを確認しています。
エラーメッセージ
error
1Building on the Heroku-24 stack 2-----> Determining which buildpack to use for this app 3-----> Python app detected 4-----> Using Python 3.10.12 specified in runtime.txt 5-----> Installing Python 3.10.12 6 ! Warning: A Python security update is available! 7 ! 8 ! Upgrade as soon as possible to: Python 3.10.16 9 ! See: https://devcenter.heroku.com/articles/python-runtimes 10-----> Installing pip 24.3.1, setuptools 70.3.0 and wheel 0.45.1 11-----> Installing SQLite3 12-----> Installing dependencies using 'pip install -r requirements.txt' 13 Collecting blinker==1.9.0 (from -r requirements.txt (line 1)) 14 Downloading blinker-1.9.0-py3-none-any.whl.metadata (1.6 kB) 15 Collecting certifi==2024.12.14 (from -r requirements.txt (line 2)) 16 Downloading certifi-2024.12.14-py3-none-any.whl.metadata (2.3 kB) 17 Collecting cffi==1.17.1 (from -r requirements.txt (line 3)) 18 Downloading cffi-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB) 19 Collecting charset-normalizer==3.4.1 (from -r requirements.txt (line 4)) 20 ~~長すぎておさまらないので省略~~ 21 Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB) 22 Downloading urllib3-2.3.0-py3-none-any.whl (128 kB) 23 Downloading werkzeug-3.1.3-py3-none-any.whl (224 kB) 24 Downloading torch-2.4.1-cp310-cp310-manylinux1_x86_64.whl (797.1 MB) 25 Downloading nvidia_cublas_cu12-12.1.3.1-py3-none-manylinux1_x86_64.whl (410.6 MB) 26 Downloading nvidia_cuda_cupti_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (14.1 MB) 27 Downloading nvidia_cuda_nvrtc_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (23.7 MB) 28 Downloading nvidia_cuda_runtime_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (823 kB) 29 Downloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB) 30 Downloading nvidia_cufft_cu12-11.0.2.54-py3-none-manylinux1_x86_64.whl (121.6 MB) 31 Downloading nvidia_curand_cu12-10.3.2.106-py3-none-manylinux1_x86_64.whl (56.5 MB) 32 Downloading nvidia_cusolver_cu12-11.4.5.107-py3-none-manylinux1_x86_64.whl (124.2 MB) 33 Downloading nvidia_cusparse_cu12-12.1.0.106-py3-none-manylinux1_x86_64.whl (196.0 MB) 34 Downloading nvidia_nccl_cu12-2.20.5-py3-none-manylinux2014_x86_64.whl (176.2 MB) 35 Downloading nvidia_nvtx_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (99 kB) 36 Downloading triton-3.0.0-1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (209.4 MB) 37 Downloading nvidia_nvjitlink_cu12-12.6.85-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl (19.7 MB) 38 Building wheels for collected packages: whisper 39 Building wheel for whisper (setup.py): started 40 Building wheel for whisper (setup.py): finished with status 'done' 41 Created wheel for whisper: filename=whisper-1.1.10-py3-none-any.whl size=41119 sha256=842737c0fc405c7cdf8cdec55426db36933fa5e9a2ca1e7f4f265fbef7f342e8 42 Stored in directory: /tmp/pip-ephem-wheel-cache-_00laqfu/wheels/aa/7c/1d/015619716e2facae6631312503baf3c3220e6a9a3508cb14b6 43 Successfully built whisper 44 Installing collected packages: mpmath, urllib3, typing_extensions, tqdm, threadpoolctl, sympy, six, safetensors, regex, PyYAML, pycparser, pillow, packaging, nvidia-nvtx-cu12, nvidia-nvjitlink-cu12, nvidia-nccl-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, numpy, networkx, more-itertools, MarkupSafe, llvmlite, joblib, itsdangerous, idna, fsspec, filelock, click, charset-normalizer, certifi, blinker, whisper, Werkzeug, triton, scipy, requests, nvidia-cusparse-cu12, nvidia-cudnn-cu12, numba, Jinja2, cffi, tiktoken, sounddevice, scikit-learn, nvidia-cusolver-cu12, huggingface-hub, Flask, torch, tokenizers, transformers, sentence-transformers 45 Successfully installed Flask-3.1.0 Jinja2-3.1.5 MarkupSafe-3.0.2 PyYAML-6.0.2 Werkzeug-3.1.3 blinker-1.9.0 certifi-2024.12.14 cffi-1.17.1 charset-normalizer-3.4.1 click-8.1.8 filelock-3.16.1 fsspec-2024.12.0 huggingface-hub-0.27.1 idna-3.10 itsdangerous-2.2.0 joblib-1.4.2 llvmlite-0.43.0 more-itertools-10.6.0 mpmath-1.3.0 networkx-3.4.2 numba-0.60.0 numpy-2.0.2 nvidia-cublas-cu12-12.1.3.1 nvidia-cuda-cupti-cu12-12.1.105 nvidia-cuda-nvrtc-cu12-12.1.105 nvidia-cuda-runtime-cu12-12.1.105 nvidia-cudnn-cu12-9.1.0.70 nvidia-cufft-cu12-11.0.2.54 nvidia-curand-cu12-10.3.2.106 nvidia-cusolver-cu12-11.4.5.107 nvidia-cusparse-cu12-12.1.0.106 nvidia-nccl-cu12-2.20.5 nvidia-nvjitlink-cu12-12.6.85 nvidia-nvtx-cu12-12.1.105 packaging-24.2 pillow-11.1.0 pycparser-2.22 regex-2024.11.6 requests-2.32.3 safetensors-0.5.2 scikit-learn-1.6.1 scipy-1.15.1 sentence-transformers-3.3.1 six-1.17.0 sounddevice-0.5.1 sympy-1.13.3 threadpoolctl-3.5.0 tiktoken-0.8.0 tokenizers-0.21.0 torch-2.4.1 tqdm-4.67.1 transformers-4.48.0 triton-3.0.0 typing_extensions-4.12.2 urllib3-2.3.0 whisper-1.1.10 46-----> Discovering process types 47 Procfile declares types -> web 48-----> Compressing... 49 ! Compiled slug size: 2.8G is too large (max is 500M). 50 ! See: http://devcenter.heroku.com/articles/slug-size 51 ! Push failed
該当のソースコード
requirements.txt
1blinker==1.9.0 2certifi==2024.12.14 3cffi==1.17.1 4charset-normalizer==3.4.1 5click==8.1.8 6filelock==3.16.1 7Flask==3.1.0 8fsspec==2024.12.0 9huggingface-hub==0.27.1 10idna==3.10 11itsdangerous==2.2.0 12Jinja2==3.1.5 13joblib==1.4.2 14llvmlite==0.43.0 15MarkupSafe==3.0.2 16more-itertools==10.6.0 17mpmath==1.3.0 18networkx==3.4.2 19numba==0.60.0 20numpy==2.0.2 21# openai-whisper==20240930 22packaging==24.2 23pillow==11.1.0 24pycparser==2.22 25PyYAML==6.0.2 26regex==2024.11.6 27requests==2.32.3 28safetensors==0.5.2 29scikit-learn==1.6.1 30scipy==1.15.1 31sentence-transformers==3.3.1 32six==1.17.0 33sounddevice==0.5.1 34sympy==1.13.3 35threadpoolctl==3.5.0 36tiktoken==0.8.0 37tokenizers==0.21.0 38# torch==2.2.2+cpu 39tqdm==4.67.1 40transformers==4.48.0 41typing_extensions==4.12.2 42urllib3==2.3.0 43Werkzeug==3.1.3 44whisper==1.1.10 45 46#内容を変更(追記) 47--extra-index-url https://download.pytorch.org/whl/cpu 48torch==2.2.2+cpu 49
ファイルサイズの確認
eroku run bash -a voice-command-quest Running bash on ⬢ voice-command-quest... up, run.5424 ~ $ du -ha --max-depth 6 --threshold=2MB /app | sort -hr $ du -ha --max-depth=6 --threshold=500KB . | sort -hr $
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
- 番号リストtensorflowのバージョン
→サイズが大きくなってしまっているということを調べて真っ先に出てきたエラー。
requirements.txtにtensorflowはないので、使われていないと思う。
1.番号リスト番号リスト番号リストSlug Sizeを簡単に減らす方法
→そもそも最初にデプロイできていないので、
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404
のようにcurlでエラーが出る
- torch==2.1.0+cpuとしてGPUを使わないようにする(chatGPTより)
メッセージ特に変わらず...
補足
実行環境
mac: sonoma14
使用言語:
Python 3.10.12
*音声解析についての処理があり、
whisper, sentence_transfomerを使用

回答1件
あなたの回答
tips
プレビュー