AidemyでAIアプリ開発講座を受講中、成果物が最終課題になっていますが、デプロイする際にエラーが出ました。
remote: -----> Compressing...
remote: ! Compiled slug size: 537.8M is too large (max is 500M).
remote: ! See: http://devcenter.heroku.com/articles/slug-size
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: e4595e8051e33d37be4a954505b5953e9b664485
remote: !
remote: ! We have detected that you have triggered a build from source code with version e4595e8051e33d37be4a954505b5953e9b664485
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to アプリ名.
remote:
To https://git.heroku.com/アプリ名.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/アプリ名.git'
これを簡単に翻訳すると
リモート: !コンパイルされたスラッグ サイズ: 537.8M は大きすぎます (最大は 500M です)。
ソース コードからビルドをトリガーしたことが検出されました
リモート: !少なくとも2回。この動作の一般的な原因の 1 つは、別のブランチからコードをデプロイしようとすることです。
警告 – このコードの同じバージョンが既にビルドされています
とのこと。(アプリ名のところは”アプリ名”と書き直しています)
以前にアプリのデプロイに失敗した時に通信障害などでストップしてその履歴がまだ残っているのでエラーが出てしまいました。
不要なファイルを削除
エラー解決のために次のコマンドを実行
rm -rf .git
これはrm コマンドのオプションとして-r
fを指定することで、強制的にフォルダ削除が行えるようになります。
そして次に
heroku destory アプリ名
これで今までに実行したアプリの履歴が削除されました。
本当に削除しても大丈夫?と聞かれるので y+enterを押して実行。
そうするとアプリ名を入力してと言われるのでアプリ名を入力。
その後デプロイするために以下を実行
git init
git add .
git commit -m "new"
heroku create アプリ名
git push heroku master
今度は新たなエラーが出ました。
remote: ! Compiled slug size: 537.8M is too large (max is 500M).
remote: ! See: http://devcenter.heroku.com/articles/slug-size
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to アプリ名.
remote:
To https://git.heroku.com/iebe-bulube.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/アプリ名.git'
モデルサイズが大きいのでエラーが出ました。
モデルサイズの変更
今回、pythonのバージョンを新しいものに変更するためにrequirements.txtの中身を全てバージョンアップするように設定してあったので全てバージョンアップしないように変更。
absl-py==0.9.0
astor==0.8.1
bleach==3.1.5
bottle==0.12.18
click==7.1.2
certifi==2020.6.20
chardet==3.0.4
flask==2.0.1
future==0.18.2
gast==0.3.3
grpcio==1.31.0
gunicorn==20.0.4
h5py==2.10.0
html5lib==1.1
itsdangerous==2.0
idna==2.10
Jinja2==3.0.1
line-bot-sdk==1.16.0
Markdown==3.2.2
MarkupSafe==2.0
numpy==1.18.0
oauthlib==3.1.0
pillow==7.2.0
protobuf==3.12.4
PyYAML==5.4.1
python-dotenv==0.14.0
requests==2.25.1
scipy==1.4.1
six==1.15.0
tensorboard==2.3.0
tensorflow-cpu==2.3.0
termcolor==1.1.0
urllib3==1.26.5
Werkzeug==2.0.0
そして以下のコードを実行
git add requirements.txt
git commit -m "new"
git push heroku master
ここでデプロイしたら再度エラー。。。
今度はruntime.txtの中身がpythonの新しいバージョンになるように設定していて、古いバージョンに変更するのを忘れてしまっていたのでまた変更。
python-3.8.10
次にデプロイするために以下を実行
git add runtime.txt
git commit -m "new"
git push heroku master
これでようやく無事にHerokuへデプロイすることができました。
補足。
この後にhtmlとcssを変えたので新たにデプロイする必要があるので以下のコマンドを実行しました。
git add .
git commit -m "update"
heroku create iebe-bulube
git push heroku master
これは際デプロイする時に必要なコマンドです。
今回のエラーはAidemyの講師の先生にご指導いただきながら解決することができました。
感謝です。
終わりに
エラーが出ると愕然とすることもあります。
私はAidemy受講中に沢山のエラーにぶち当たっています。
AIスクール[Aidemy]を受講中に沢山エラーにぶつかり、解決策を講師の先生に沢山教えていただけるのは、エラーがなくスムーズに進むことよりも貴重なことだと思っています。
終了するまでにもっと色々教えていただこうと思います。
コメント