gpt4 book ai didi

python - 子进程: "Exec format error" in gekko package

转载 作者:太空宇宙 更新时间:2023-11-03 20:23:46 25 4
gpt4 key购买 nike

我正在尝试在 python 2 或 3 中运行 gekko。我只是按照教程更改了参数,然后利用 scipy.integrate 来模拟我的 MPC。它可以在我的一台计算机上运行,​​但不能在我的 NVIDIA Jetson TX2 上运行。运行 m.solve(disp=False) 时出现“Exec format error”。

两台电脑都有python2和python3。由于我也在运行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 无法正常运行。

如果我设置m = GEKKO(remote=True),它就可以工作。然而,MPC 无法实时运行,这对我来说绝对是一个问题。

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

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

它返回:

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 ServerLinux APMonitor Server并在该服务器上解决(例如 IP 地址 10.0.0.10):

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

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

  • Windows(32 或 64 位):apm.exe
  • Linux(64 位):apm
  • MacOS(64 位):apm_mac
  • Linux ARM(树莓派):apm_arm

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

关于python - 子进程: "Exec format error" in gekko package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57980021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com