BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
595 stars 104 forks source link

Local solve (remote=False) option for Linux and ARM #48

Closed APMonitor closed 5 years ago

APMonitor commented 5 years ago

The Linux (apm) and ARM (apm_arm) version of the local executable no longer requires libraries and the folder os.path.realpath(file))+'/bin/lib'. When the apm binary is missing, I get the following error when I run on Linux:

Local Solve: k2 n0 Traceback (most recent call last): File "rosenbrock.py", line 60, in m.solve(disp=False) File "/home/hedengren/.local/lib/python3.5/site-packages/gekko/gekko.py", line 661, in solve app = subprocess.Popen([apm_exe, self._model_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE,cwd = self._path, env = {"PATH" : self._path, "LD_LIBRARY_PATH" : os.path.dirname(os.path.realpath(file))+'/bin/lib' }, universal_newlines=True) File "/usr/lib/python3.5/subprocess.py", line 947, in init restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: '/home/hedengren/.local/lib/python3.5/site-packages/gekko/bin/apm'

I tried to resolve the issue by retrieving the apm executable and creating an empty lib directory as:

cd /home/hedengren/.local/lib/python3.5/site-packages/gekko/bin mkdir lib wget https://github.com/BYU-PRISM/GEKKO/tree/master/gekko/bin/apm sudo chmod 775 apm

This resolved the issue but it would be nice to have this modified in the PyPi pip distribution.

We also need a check in the Python code to determine the architecture (Windows, Linux, ARM) and use the appropriate local executable (apm.exe, apm (linux), apm_arm (ARM)).

APMonitor commented 5 years ago

Resolved with release 0.1rc1 on PyPi. GEKKO now works with local solve on Windows, Linux, and ARM Linux. There is still no local support for MacOS.