Better deployment logs and error messages for AI Platform custom prediction routine with PyTorch
I'm following this guide to deploy a PyTorch model to the AI Platform Prediction service.
Describe the issue
I get the following error no matter what I do.
ERROR: (gcloud.beta.ai-platform.versions.create) Create Version failed. Bad model detected with error: Model requires more memory than allowed. Please try to decrease the model size and re-deploy. If you continue to experience errors, please contact support.
So here's the sequence of events that a developer goes through.
- See this post. Awesome! We can deploy PyTorch models to the AI Platform.
- But wait, there's a gotcha - you can't actually install torch as describe in the post above. You have to do it this way.
- Hmm, I'm still getting this memory issue but my model directory on Google Cloud Storage is only 80mb, and my model only requires 300mb of memory locally. I continue Googling around for a while and then stumble on this post that suggests creating wheels for any package that might require a lot of memory during pip installation. I created wheels for all my packages taking into account what already exists in the runtime version, uploaded them to Google Cloud Storage and passed in those paths to the
--package-urisargument. Same error as above.- NB: this post + the docs are somewhat confusing regarding this 500mb constraint. It's unclear what the memory and storage constraints are. Does the 500mb model directory (i.e.
--origin) storage limit include the--package-urisor does--package-urisnot count toward that limit? Is the memory of the deployment environment (suppose--machine-type mls1-c1-m2) 2gb or 500mb?
- NB: this post + the docs are somewhat confusing regarding this 500mb constraint. It's unclear what the memory and storage constraints are. Does the 500mb model directory (i.e.
I even ran another test to see if I could get a different error message. First I tried to deploy my PyTorch model as one would expect. I got the error message above.
I deleted the model weights that were stored in Google Cloud Storage (the ones that would have been loaded by the predictor class) and I still got the error message.
@dizcology Could you triage this please?
FWIW, I think the issue stemmed from unsatisfied Python packages dependencies (and surely I could have done more local testing) but I still think better logs should be surfaced to the user so that they can debug deployments to the cloud.
Friendly ping @dizcology or @ericschmidtatwork could you take a look?
The problem is that the approach outlined above brings in a lot of dependencies and those get counted against the RAM usage as the downloads are stored in TMPFS. The most recent guidelines for running PyTorch can be found in the public docs and you should not hit the same issue:
https://cloud.google.com/ai-platform/prediction/docs/getting-started-pytorch-container
To answer your question, we enforce a 500 MB limit for mls1* machines and 2 Gb limit for n1* machines for files on GCS, but each machine also has a RAM limit, depending on the machine type. For a variety of reasons, 500 MB on disk can require much greater than 500 MB of RAM. In this particular case, as described above, downloading dependencies was using up RAM. This will not be the case for the approach described in the public docs.
@ToddMorrill: Looks like the more recent guidelines that @rhaertel80 provided should provide a working solution. Closing this issue for now, but please feel free to reopen if you are still experiencing issues.