I have a python script for running a tensorflow model, and I need to run this script from a PHP file (for complicated reasons) using the PHP shell_exec
function. When I run the python file with the following code:
$command = 'cd testModels/crosswalkPredict && . activate keras && python test_script.py';
$output = shell_exec($command);
I get the following error: Illegal instruction (core dumped)
I read that the issue typcally occurs when the CPU doesn't support instructions that are present in newer versions of Tensorflow. So I downgraded to Tensorflow 1.5.
However, this error does not occur when I run cd testModels/crosswalkPredict && . activate keras && python test_script.py
directly from the terminal; it only occurs when I run it from within the PHP shell_exec
function.
I have gone as far as to try the python script with only the following lines:
import tensorflow
print('Hello!')
It still gives the same error, so I know the issue occurs when all I'm doing is importing tensorflow and running the script with shell_exec
.
What could be the problem?