Deploy Tensorflow on a web server with Flask - apache

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

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.

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

Related

Silverstripe CMS gives File size zero error

I have designed a page that has upload attachments ... one image and another PDF.
The data is created in the database, however, when trying to upload a file of either type I get a server error "File Size is zero bytes".
A search of this forum yielded entries that indicate it is a permission issue of site assets folder or assets/Uploads folder. I have checked both and the permissions are correct.
The search on other platforms seems to indicate file size issues are from the PHP5.6 php.ini file settings. Both are correct and set to a value well above the 8Mb default.
The Apache2 log looks like:
[Tue Jun 06 15:11:57.167558 2017] [:error] [pid 26971] [client 192.168.1.73:50192] PHP Warning: mkdir(): Permission denied in /var/www/html/ss/framework/filesystem/Filesystem.php on line 53, referer: http://192.168.1.70/ss/index.php/admin/pages/edit/show/23
[Tue Jun 06 15:11:57.170810 2017] [:error] [pid 26971] [client 192.168.1.73:50192] PHP Warning: copy(/var/www/html/ss/assets/Uploads/news-attachments/the-satern-ring.pdf): failed to open stream: Permission denied in /var/www/html/ss/framework/filesystem/Upload.php on line 207, referer: http://192.168.1.70/ss/index.php/admin/pages/edit/show/23
This code also seems to indicate a permission issue. The folders all have the owner as root group as root and drw-rw----, files can be uploaded manually but not through the CMS.
So where do I look now?
Environment:
SS v3.6.0 theme bootstrap
OS Linux Mint 18.1
Apache 2.4 PHP 5.6
This can occur when framework does not have permission to write files to the server. If this is the case, when we upload images through the CMS the file can not be written to assets and the CMS returns a "File size zero error". The website also cannot combine files (such as JavaScript and CSS files) and cannot create new resampled images.
To help investigate this problem we can run the SilverStripe install wizard. The install wizard will notify us of issues preventing SilverStripe from running correctly.
To run the install wizard we visit http://www.example.com/install.php
The install.php is usually deleted after the site is installed, so if it is missing we will need to replace it. We can download the file from github. Here is the install.php file for SilverStripe 3.6: https://github.com/silverstripe/silverstripe-installer/blob/3.6/install.php
Once downloaded we upload this to the root directory of our webserver. Once this is done we can visit the install.php URL.
Here is a screenshot showing an example of the file permission issue warnings that the install wizard outputs:
What we want to do now is fix up all the warnings that the install wizard is reporting.
If this is a shared hosting environment we might not have the ability to fix these issues ourselves. In this case we should be able to send the install.php link to hosting support asking them fix the issues.
Once all the issues are fixed the site should work correctly. Make sure to delete the install.php when we are done.

Can't load 'C:/Apache/Perl/site/lib/auto/Apache2/ModSSL/ModSSL.dll'

I am running an Windows Server 2008 R2 Enterprise with an Apache Server installed and mod_perl & mod_ssl
I just installed Apache2::ModSSL, but i was not able to use cpan for this and had to compile it using nmake. CPAN is not working correctly on this Server and i am not able to change this.
A perl script called via https should later be able to Access the certificate the Clients used to authenticate, thats why i want to use Apache2::ModSSL to Access the SSL variables.
When i try to acess my test script after implementing
use Apache2::ModSSL;
i get an HTTP500 error from the Server.
The Servers error log states
[Fri Jul 01 15:01:58 2016] [error] [client 10.217.139.184] failed to resolve handler `ssl::hello': Can't load 'C:/Apache/Perl/site/lib/auto/Apache2/ModSSL/ModSSL.dll' for module Apache2::ModSSL: load_file:The specified module could not be found at C:/Apache/Perl/lib/XSLoader.pm line 68.\n at C:/Apache/Perl/site/lib/Apache2/ModSSL.pm line 8\nCompilation failed in require at ssl/hello.pm line 7.\nBEGIN failed--compilation aborted at ssl/hello.pm line 7.\nCompilation failed in require at (eval 3) line 3.\n
When i check the file Location, ModSSL.dll is stored at exact this path. I also checked the file Access and granted Full acess to All Users, System, Administrators etc. Apache was restarted multiple times and it did not Change anything.
When i tried to execute it in a cmd, obviously there was no Connection to check but i could execute
use Apache2::ModSSL;
print Apache2::ModSSL->VERSION;
without Problems.
How to solve the issue with loading the module within Apache?
Server readme states
This is a binary distribution for Win32 of Perl 5.8.7 and Apache
2.0.54, together with mod_perl-2.0.1, mod_ssl / OpenSSL (0.9.7g), and php-4.3.11, all built with VC++ 6.0 (SP5).
cl -version states
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
nmake -version states
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Without investigating too deeply, the most likely reason for your problem is that perl, OpenSSL, mod_ssl etc where compiled with a different compiler than the one you used to build Apache::ModSSL.
It seems to me that the module only tries the XS version if it thinks it's running under mod_perl. You can see this in the module's Apache2/ModSSL.pm:
XSLoader::load __PACKAGE__, $VERSION
if( exists $ENV{MOD_PERL} and $ENV{MOD_PERL}=~/mod_perl/ );
It only tries to load the XS component if the MOD_PERL environment variable exists and it contains mod_perl. My guess is if you did:
C:\> set MOD_PERL=mod_perl
C:\> perl -MApache2::ModSSL -e "print $Apache2::ModSSL::VERSION"
you would encounter problems.
In addition, I feel I must emphasize the facts that your OpenSSL version in addition to perl and php seem too old to be used safely.

mod_perl "use" randomly fails

We have a web interface for our software using perl and Apache with mod_perl. On a recent Ubuntu 14 installation (Apache 2.4.7, perl version 5.18.2) we've had problems with it randomly stopping working with the error below. This will happen after a random amount of time (eg a few hours or days), has not happened on any previous Ubuntu or CentOS installation, and we've only been able to temporarily resolve it by restarting Apache.
The difficulty in debugging it stems from the fact that it runs fine for a while, processing hundreds or thousands of requests, and we've not been able to identify any particular trigger for it to stop working.
Would anyone have ideas on how to debug and resolve it? Thank you.
The following is the error message. It is repeated with every web request until Apache is restarted. The Utils.pm mentioned is part of our software, and is "use"d in line 2 of index.pl. Utils.pm itself "use"s quite a few other modules.
[Sun Jul 27 19:26:18.110765 2014] [:error] [pid 26316:tid 139927794730752] Attempt to reload Utils.pm aborted.\nCompilation failed in require at /path/to/index.pl line 2.\nBEGIN failed--compilation aborted at /path/to/index.pl line 2.\n
I approach these problems through process of elimination. If a deployment isn't fully successful, I want to know how it differs from fully successful deployments.
I would begin by examining the versions of Perl dependencies. Different distributions might include different versions of non-core modules. If your deployment procedure includes pulling dependencies from CPAN, you may have newer versions of modules on the recent deploy than on previous deploys.
If I found that the dependencies differed, I'd deploy the same versions from an acceptable deployment to the new deployment. If it fixed the problem, I'd know that I have to refine the process for future deployments. If it didn't fix the problem, I'd move on to other identifiable differences between acceptable and unacceptable deployments. "Identifiable" depends on what resources I have at my disposal. I'm an almost-adequate system administrator, so I'd be likely to consult with a colleague to help me identify inconsistencies at that level.
We know that there are environments where the software works as expected. We might not be able to isolate the precise root-cause, but it is reasonable to expect that we can make the environment more hospitable to the application.
The problem seems to be resolved by disabling Apache2::Reload with the following in apache2.conf:
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off

running amixer through cgi

I'm trying to run shell commands (amixer set Master 1+ for example) through web interface.
I have set up apache on the target server (Ubuntu 12.04, desktop) and tested the setup with a simple Hellow world! script. Everything works fine but if I try to do this with amixer I don't get any result. I don't even get any output though if I try to print the output to a file the file is created.
I'm not sure if this is configuration issue or a missing command issue.
How can I achieve this?
Edit:
I attach here part of /var/log/apache2/error.log which I think is relevant
amixer: Mixer attach default error: No such file or directory [Sat May
26 17:54:05 2012] [error] [client 192.168.1.103] File does not exist:
/var/www/favicon.ico
I'm sorry for the late respond, due to unexpected maintenance work, I had to leave home for several days.

Problem Configuring RApache on OS X 10.5.8

I've been trying to get RApache set up properly on my Macbook Pro running OS X 10.5.8. After installing RApache successfully (I think), I added the following to the httpd.conf file as suggested in the manual.
LoadModule R_module /apache/module/path/mod_R.so
ROutputErrors
<Location /RApacheInfo>
SetHandler r-info
</Location>
With these additions, I was then able to successfully go to http://localhost/RApacheInfo and see the status information. If I add the following additional line,
REvalOnStartup "library(brew)"
I can no longer load the RApacheInfo page successfully.
I don't know what the issue is here. Without the REvalOnStartup call, I'm seeing the following in the Apache error log.
[Fri Feb 26 11:36:36 2010] [notice] Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.7l DAV/2 mod_R/1.1.8 R/2.10.1 configured -- resuming normal operations
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
Not a good sign. Any thoughts on what might be going on? Or things to check?
Chris
I'm not sure why you're getting this error on just loading a library, but we've seen this issue on Leopard due to Apple's freetype/fontconfig/cairo libraries calling CoreFoundation calls:
http://finzi.psych.upenn.edu/R/Rhelp02/archive/118681.html
How did you install R?
I tried reproducing your issue on Snow Leopard with stock apache2, binary R 2.10.1 from CRAN, Xcode 3.2.1, and rapche 1.1.8 but no luck. My setup worked like a champ.
I don't have access to Leopard anymore, so my best suggestion is to use gdb to break on that really long system call. You will want to remove the REvalonStartup directive and replace it with a handler call which does the same, configure apache to spawn only one child process (hence the whole fork thing) and connect gdb to it. Then point your web browser to your handler url and see if gdb breaks on the function and then look at the stack trace.... Pretty lame I know, but that's all I got for now.