Deploy pretrained Pytorch model on Google Cloud

I write a Flask + Pytorch code, try to do a prediction with pre-trained model on the server. But I met some problem when installing the dependency:

I initially used the following commands to install PyTorch in the “lib” folder.:

pip install -t lib 
pip install -t lib torchvision 

But when I run the code in a virtual environment, the error shows:

import torch._dl as _dl_flags
File "/home/yifang/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/", line 1093, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named torch._dl

Everything works fine if I run the PyTorch Program locally.

So does anyone have experience in deploying PyTorch model on Google Cloud or any other server?

Hi Yifang,

I am also encountering this problem. Did you find a solution?