子进程:gekko 包中的 "Exec format error"

Subprocess: "Exec format error" in gekko package

我正在尝试 运行 gekko in python 2 或 3。我只是按照教程更改了参数,然后使用 scipy.integrate 来模拟我的 MPC。它适用于我的一台计算机,但不适用于我的 NVIDIA Jetson TX2。并在 运行ning m.solve(disp=False).

时得到 "Exec format error"

两台电脑都有python2和python3。由于我也是运行ning ROS,所以想用python2转运行脚本。最初我认为可能是使用 python2 解释导致了问题,所以我写了另一个脚本利用子进程将我的 mpc 和模拟器解释为 python3。然而,这个问题仍然存在。问题似乎出在 gekko 包中。我确定这是一个环境错误,因为脚本在我的个人计算机上 运行 没问题。目前我是 运行宁 Ubuntu 16.04.

def example_MPC(t_init, x, u_init):
    m = GEKKO(remote=False)
    dt = 0.5
    m.time = np.linspace(t_init,10+t_init,21)
    #...
    m.solve(disp=False)       # <-- The error appears on this line
    #...
    return p.value[1]

这是来自终端的错误信息:

  Traceback (most recent call last):
  File "ode_solver.py", line 53, in <module>
    simulation()
  File "ode_solver.py", line 34, in simulation
    u[i] = example_MPC(t[i-1], v0, u[i-1])
  File ".../src/MPC_test.py", line 34, in example_MPC
    m.solve(disp=False)
  File "/home/nvidia/.local/lib/python3.5/site-packages/gekko/gekko.py", line 1880, in solve
    env = {"PATH" : self._path }, 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)
  OSError: [Errno 8] Exec format error

编辑:

我找到了 apm 文件夹位置。当我尝试 运行 apm

./apm

命令给了我这个:

-bash: ./apm: cannot execute binary file: Exec format error

我假设这意味着在我的 TX2 上,apm 未正确 运行ning。

如果我设置 m = GEKKO(remote=True),它会起作用。但是MPC不能实时运行,这对我来说绝对是个问题。

我现在正尝试在本地桌面上解决这个问题。服务器参数只是本地 ip 地址吗?我设置:

m = GEKKO(remote=True, server="192.168.1.136")

它returns:

Traceback (most recent call last):
File ".../src/ode_solver.py", line 53, in <module>
    simulation()
  File ".../src/ode_solver.py", line 34, in simulation
    u[i] = example_MPC(t[i-1], v0, u[i-1])
  File ".../src/MPC_test.py", line 34, in example_MPC
    m.solve(disp=False)
  File ".../.local/lib/python2.7/site-packages/gekko/gekko.py", line 1992, in solve
    raise ImportError('Results files not found. APM did not find a solution or the server is unreachable.')
ImportError: Results files not found. APM did not find a solution or the server is unreachable.

设置 m = GEKKO(remote=True, server="http://192.168.1.136") 会产生同样的问题。

您可以远程解决(需要联网):

m = GEKKO(remote=True)

或者设置 Windows APMonitor Server or a Linux APMonitor Server 并在该服务器上解决(例如 IP 地址 10.0.0.10):

m = GEKKO(remote=True,server='http://10.0.0.10')

问题是 NVIDIA Jetson TX2 六核 ARMv8 64 位 CPU 没有兼容的可执行文件,否则 Python 没有选择正确的可执行文件。您可以查看 apm_arm 可执行文件是否会 运行 在您的计算机上,方法是在 Lib/site-packages/gekko/bin 中找到它或从当前支持的 local executables 下载:

  • Windows(32 位或 64 位):apm.exe
  • Linux(64 位):apm
  • MacOS(64 位):apm_mac
  • Linux ARM (Raspberry Pi): apm_arm

如果它不 运行 或不在此列表中,那么我建议将 remote=True 与本地服务器或公共服务器一起使用。我将 NVIDIA Jetson TX2 本地可执行文件添加为 feature request in the GEKKO repository on GitHub.