Cloud deployment of Caffe

782 views
Skip to first unread message

pmb.fe...@campus.fct.unl.pt

unread,
May 4, 2016, 1:36:19 PM5/4/16
to Caffe Users
Hello all,

I currently have to create a cloud hosted web application that uses Caffe to classify images.

Does anyone have any insight on how Caffe can be deployed to the cloud?
I have seen the web demo code on the git repository but I'm finding it difficult to understand how to deploy this code to a cloud such as Heroku or Azure since Caffe is not listed in the requirements.txt.

Can anyone help?

Thank you in advance,

Andriy Lysak

unread,
May 4, 2016, 2:35:30 PM5/4/16
to Caffe Users
I never used Azure or Heroku.

If you can explain a bit more, maybe we can figure this out.

So this cloud: would it run a LAMP stack or something else? 
What sort of operating system would you be using?

Regards,
Andriy

Felix Abecassis

unread,
May 4, 2016, 3:49:14 PM5/4/16
to Caffe Users
Hello,

The following demo code might help you building a web service for classifying images with Caffe:
https://github.com/NVIDIA/gpu-rest-engine
Deployment is made using Docker.

Pedro Ferreira

unread,
May 4, 2016, 5:27:30 PM5/4/16
to Caffe Users
Thank you both for the quick replies

Andriy, my plan was to create a web app that used the Caffe framework to classify images, and that web app would be hosted in a cloud server. However I believe I could also use an Azure Virtual Machine and so have access to different OSes to deploy my app. Sorry if I didn't answer your question, I'm still trying to make sense of all this myself

Felix, sounds interesting and useful. Will definitely look into that, thank you

Andriy Lysak

unread,
May 5, 2016, 1:31:01 PM5/5/16
to Caffe Users
So I have a similar setup for my purposes. What I have (its probably not the best setup, but it works for me): A LAMP server that has a php page where i post my image in base64 encoding (you can just set up drag and drop if you want, there are tutorials on this online).

Then the php script calls a java program that does some optimizations on the image (you probably wont need this, instead save the base64 image as a file a .jpeg or .png, your choice).

After the file is saved I call a python script (passing the image file name to it) that classifies the image and returns the result so that the php script can display it for me in a browser.

This works well for me, I found on a normal LAMP server with 8 GB of RAM and a GTX 980 i can run 6 simultaneous classification pages with no issues.

Regards,
Andriy 

Jan

unread,
May 6, 2016, 7:38:24 AM5/6/16
to Caffe Users
Just for reference: A LAMP server to do this simple task sounds like massive overkill to me, like "shooting flies with a cannon".

With the Flask framework you can create a webservice to run caffe on an uploaded image in just a few lines of python code. It's quite simple and well-documented. And you don't need to set up some full-fledged webserver and php and whatnot.

Jan

Andriy Lysak

unread,
May 6, 2016, 12:49:31 PM5/6/16
to Caffe Users
Jan,

You are correct, that could work too! I was just sharing what i have set up. For my purposes a LAMP server is better because I have other things running on it.

Best Regards,
Andriy

Jan

unread,
May 9, 2016, 4:16:22 AM5/9/16
to Caffe Users
Ok, if you need it for other things too you may be justified running a LAMP setup. From the post it sounded like its only purpose was to run the caffe script. And of course you can do whatever you want. I just tried to provide some hints. I myself was very surprised to learn how easy it is to set up a simple webserver when using the right tools/frameworks (flask in this case).

Jan

Pedro Ferreira

unread,
May 10, 2016, 12:24:07 PM5/10/16
to Caffe Users
Jan, yes using the Flask framework would be perfect for me.
My doubts about this are on how to configure all of Caffe's dependencies so the web app runs the script.

For instance, in the Git web-demo (https://github.com/BVLC/caffe/tree/master/examples/web_demo):

The requirements.txt does not mention Caffe or any of its dependencies. However, in the app.py script it imports caffe. This makes sense in a localhost situation, where Caffe is installed in the local machine, but how would it work when you want to launch your own web app calling caffe?

Thank you

Felix Abecassis

unread,
May 10, 2016, 12:49:25 PM5/10/16
to Caffe Users
I don't understand the problem, you just prepare a machine by installing caffe and all its dependencies, then you start an HTTP server on this machine, it waits for HTTP requests and perform classification.
Your other services (e.g. your website) can now perform classification by sending an HTTP request to the classification server that is possibly on another machine.

Jan

unread,
May 11, 2016, 4:13:45 AM5/11/16
to Caffe Users
I share Felix's viewpoint. I am not sure where the problem is. If you want to use flask, you'd need at least ssh access to that server, and in that case you also can compile and install caffe there. Currently there is no other option to get caffe running, so you cannot just specify something in the requirements.txt and get caffe installed that way. That is why there is no entry for caffe in that file. Nevertheless it is a dependency of that web_demo.

Oh wait, I think there is a docker image that you may be able to utilize/customize (if that is an option for you). I have never used it, but it may be beneficial for some people.

Jan
Reply all
Reply to author
Forward
0 new messages