Mostafa
Mostafa

Reputation: 1551

Deploy Tensorflow on a web server with Flask

I am trying to deploy a Flask web app with tensorflow on an AWS server ( AMI ID: Deep Learning (ami-77e0da1d)), for an image classification app.

When I use tensorflow in the server, it works normally, but when I try to use it with the app, I get:

No data received ERR_EMPTY_RESPONSE

In the end of the error.log file, I have:

F tensorflow/stream_executor/cuda/cuda_dnn.cc:204] could not find cudnnCreate in cudnn DSO; dlerror: /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: cudnnCreate [Sat May 14 11:30:54.124034 2016] [core:notice] [pid 1332:tid 139695334930304] AH00051: child pid 2999 exit signal Aborted (6), possible coredump in /etc/apache2

My CuDNN version: 4.0.7

I can provide more details if necessary

Upvotes: 1

Views: 1661

Answers (2)

mrry
mrry

Reputation: 126184

The value of LD_LIBRARY_PATH is being cleared before starting your web app starts, for security reasons. See for example this question, which observes that the value of os.environ['LD_LIBRARY_PATH'] is empty inside the Flask app, even though it may be set when you launch Apache.

There are at least a couple of options:

  • You could use Apache's mod_env to set the environment variables that are propagated to your Flask app.

  • Based on this answer, you could modify your script to perform a subprocess call, and set the LD_LIBRARY_PATH to /usr/local/cuda/lib64 for the subprocess.

Upvotes: 1

Mostafa
Mostafa

Reputation: 1551

I solved my problem by deploying on a CPU instead of a GPU, and it was enough for me.

Upvotes: 0

Related Questions