Search code examples
google-cloud-platformgoogle-cloud-rungcp-ai-platform-training

Run AI Platform Notebook with Cloud Run


I have a python script generate_trends.py stored with the instance name python-20201013-153823 as a notebook inside the AI Platform. What would be the best way to run that script directly from a cloud run using Flask?


Solution

  • Cloud Run can serve stateless container that answers to HTTP request.

    If you create a Flask server, with an entry point which trigger your script (call the processing function in your generate_trends.py file), package this in a container and deploy.

    Take care of this:

    • No GPU are attachable to a Cloud Run instance
    • No dist can be attached to a Cloud Run instance. You have a in-memory writable directory /tmp, but it's not persistent and in memory. Use databases or cloud Storage to persist states
    • Only 4 CPUs and up to 4 Gb of memory. You can't add more on an instance
    • The request must be responded in less than 60 minutes
    • You can't perform processing outside request handling (batch processing for example). CPU is throttled outside request processing period.