This article will be a bit different than my usual business-oriented articles. In a recent article, I gave the impression that DigitalOcean is not a good place to deploy Deep Learning systems. However, there are some good use cases for deploying to DigitalOcean that save cost and complexity.
We were recently tasked by a client to deploy a regression model to the cloud. The training was performed on a K20 GPU.

We tried using DigitalOcean’s "Machine Learning and AI" one click install on a new droplet with 2GB RAM. The results were pretty amazing.
To start, we upgraded tensorflow with this:
pip install --upgrade tensorflow
#to resolve ImportError: 'load_weights' requires h5py.
pip3 install --upgrade h5py
To upgrade keras (optional) use this:
pip install keras --upgrade
Out of the box problems getting the code to work on Keras 2. Read the right version of the documentation: https://faroit.github.io/keras-docs/2.0.8/ and check your version with this:
import keras
print(keras.__version__)
Execution Time Results on DigitalOcean
A DNN (MLP) with 7 layers trains in 11.4 seconds (for 10,000 samples with 20 inputs and 10 output classes). Testing on 1000 samples took 968 ms. That’s FAST. Here is the code:
To time the 1000 model predictions, simply go like this:
An LSTM (for sequence prediction) went really fast as well. We use this kind of model to predict stuff like stock prices. Another interesting use of LSTMs is regression, but let’s stick to the example. The example took 33.5 s for 144 data points. BUT, the model predictions (excluding training) took only 16 milliseconds!

A CNN(vgg19) 2GB was not enough memory to run the model, so I did this on an 8GB instance. For a few other CNNs on the 2GB I similarly got ResourceExhaustedError and other junk. No big deal. On the 8GB RAM instance, it works like a charm. It takes 8.6 seconds to load up the model and get one result, but the model prediction itself is much faster.
Processing 100 images and doing a model prediction for each one took 4min 23s. So, in seconds that’s 240+23 = 263 seconds. Dividing by the number of images, that’s 2.63 seconds. Not great. Here is the timing code:
A word embedding model in word2vec (Google news) was my next step, but alas, I have to get back to real work. Embedding models have a memory size problem like CNN.
Cost results on DigitalOcean
Well, doing the DNN and LSTM on 2 $20/month instance is WAY cheaper than a 1K/month p2 or p3 instance on AWS. For these smaller models it makes a lot of sense. For the bigger CNN and word2vec models, there is not enough compute (no GPU) or RAM (for big embedding models) to make DigitalOcean attractive. That could change, if, for example, there is a route to load word2vec models from the SSD instead of RAM. I mean, why not? It’s basically just a big memory pad. So that would solve the word embedding problems, but what about CNN? That’s a tougher one. I think for image processing a GPU is still going to be top of the line for a long time to come.
If you enjoyed this article on deep learning in the cloud, then please try out the clap tool. Tap that. Follow us on medium. Share a link to this article. Go for it. I’m also happy to hear your feedback in the comments. What do you think?
If you liked this article, have a look at some of my most read past articles, like "How to Price an AI Project" and "How to Hire an AI Consultant." In addition to business-related articles, I also have prepared articles on other issues faced by companies looking to adopt deep machine learning, like "Machine learning without cloud or APIs."
Happy Coding!
-Daniel [email protected] ← Say hi. Lemay.ai 1(855)LEMAY-AI
Other articles you may enjoy: