Recently I tried to deploy a ML model on the SAP Cloud Platform. The step has been described in detail in the blog post – Run Machine Learning model on SAP Cloud Platform. You might have used a different version of libraries ML model or you may have different entitlement in your SAP Cloud Platform. Depending on the situation, you may face some issues during the deployment on the SAP Cloud Platform. The idea of this blog post is to highlight the common error faced during deployment and their troubleshooting.
Here I assume that:
i. You have already built your ML model and you are ready with the model pickle file.
ii. You have also configured the metadata files – Procfile, runtime.txt, requirements.txt, and Mainfest.yml file.
iii. Your space is created on Cloud Foundry environment
iv. CLI is installed on Local PC(see the official page for the installation)
I strongly recommend you keep the debugger mode on in the Flask API file. This will generate the necessary logs that would help to troubleshoot in case we face some errors.
app.config["DEBUG"] = True
In this blog, I will discuss below errors that I encountered during deployment. I will also list the steps that I took to resolve those errors:
- For application ‘app’: Routes quota exceeded for organization ’85XXX7aetrial_India1′.
- BuildpackCompileFailed – App staging failed in the buildpack compile phase FAILED
- Instance Starting… and finally it will CRASHED!
1. For application ‘app’: Routes quota exceeded for organization ’85XXX7XXtrial_India1′.
This error could be due to many issues. This blog post (Setting up trial CF subaccount) describes a few of them. I went through this blog post and checked all the suggested points – Setting a subaccount or increasing the Entitlement can help you as well. However, in my case, I have multiple trial account (I don’t remember, but one seems a previously created and expired one) and I was selecting the wrong one. After selecting the correct trial account, I didn’t face this error.
2. BuildpackCompileFailed – App staging failed in the buildpack compile phase FAILED
This error can occur due to many reasons and we need to debug/see logs to get a clue here. You can run the command cf logs <APP_NAME> – -recent on the command prompt to see what’s happening during deployment. In my case, as you can see below, I was supplying the wrong version of python in the runtime.txt file. I changed the python version from 3.8.5 to 3.8.7 in my runtime.txt file.
You need to adjust your Cloud Foundry metadata files according to the logs. Once you correct the metadata files, please try to push the application again (cf push <APP_NAME) and hopefully you would succeed.
3. Instance not starting and then finally CRASHED (start unsuccessful)
To know why the application has crashed, we need to run the command to cf logs <APP_NAME> – -recent to see the logs. In my case, it seems it was happening as I was not making the right call to run my FLASK API and hence it was failing with error: exit_description: APP/PROC/WEB: Exited with status 1, reason: CRASHED
I changed the api.run() in my FLASK API file to the below code and re-deployed my application.
if __name__ == '__main__': if cf_port is None: app.run(host='0.0.0.0', port=5000, debug=True) else: app.run(host='0.0.0.0', port=int(cf_port), debug=True)
In this blog post, we have seen some of the most common errors that we get while deploying a ML model on the SAP Cloud Platform. I am sure the errors must be limited to what I mentioned here in this blog post. However, the process to troubleshoot the error and fixing them would remain less or more the same. I hope this blog would help you and you may have some easy time deploying your ML model. Thanks for reading so far and I would like to hear your feedback.