I try to deploy a google cloud function with dependencies via requirements.txt. Deployment takes terribly long and fails with this message:
(gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"cacheStats": [{"status": "MISS", "hash": "ebbabef833cbc5bf98d2562c9f28bd5ab91e1a867134bb0c08f84397510ff774", "type": "docker_layer_cache", "level": "global"}, {"status": "MISS", "hash": "ebbabef833cbc5bf98d2562c9f28bd5ab91e1a867134bb0c08f84397510ff774", "type": "docker_layer_cache", "level": "project"}]}
I figured out, that the requirements.txt seems to be the problem, I get the same behaviour when I just create a python3.7 cloud function over web console (with the HelloWorld Example) and paste requirements there. requirements.txt looks like:
Flask==1.0.2
dill>=0.2.8
numpy>=1.15.0
requests>=2.20.0
six==1.12.0
spacy>=2.1.0
torch>=1.0.0
torchtext>=0.3.1
I have several other examples working with requirements.txt, but I don't see the point here. And I don't know if there is a way to further debug this.
Ideas anyone?
It seems that pytorch is causing the problem, it works by directly pointing to the URL of the whl file like
...
spacy>=2.1.0
https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
torchtext>=0.3.1
The problems seems to be related to cuda, the URL above points to the torch version without cuda.
PyTorch ships a distribution on PyPI with CUDA/Nvidia GPU support by default, but the Cloud Functions runtime doesn't have GPU support, or the necessary system libraries.
Instead, you should use the URL provided by https://pytorch.org/ when selecting:
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
Which would make your requirements.txt
:
Flask==1.0.2
dill>=0.2.8
numpy>=1.15.0
requests>=2.20.0
six==1.12.0
spacy>=2.1.0
https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
torchtext>=0.3.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With