我正在尝试在 xeon phi 协处理器上执行二进制文件,它返回“bash:无法执行二进制文件”。所以我试图找到如何查看错误日志或让它显示当我告诉它执行导致它不起作用时发生的事情。我已经尝试过了bash --verbose
,但它没有显示任何其他信息。有任何想法吗?
2 回答
您没有指定编译可执行文件的位置,也没有指定尝试执行的位置。要在主机系统上编译程序以直接在协处理器上执行,您必须:
- 如果使用英特尔编译器之一,请将 -mmic 添加到编译器命令行
- 如果使用 gcc,请使用 MPSS 提供的交叉编译器 (/usr/linux-k1om-4.7) - 但是请注意,gcc 编译器没有利用协处理器上的矢量化
如果您想直接在协处理器上编译,您可以使用 MPSS 用户指南中关于安装额外 rpm 文件的说明,从为协处理器(在 mpss-/k1om 中找到)提供的额外 rpm 文件中安装必要的文件。要在协处理器上运行程序,如果您已在主机上编译它,您必须:
- 在您自己 ssh 到协处理器以执行代码之前,使用 scp 将您的可执行文件和所需的库复制到协处理器。
- 在主机上使用 micnativeloadex 命令 - 您可以在主机上找到该命令的手册页。
如果您正在使用卸载模型编写程序(部分工作使用主机完成,然后一些工作被传递给协处理器),您可以使用英特尔编译器在主机上进行编译,无需特殊选项。但是请注意,无论您使用什么方法,任何与协处理器可执行文件一起使用的库都需要为协处理器构建它们自己。默认库存在,但是您添加的任何库,除了您为主机系统制作的任何版本之外,您还需要为协处理器构建一个版本。我强烈推荐您在https://software.intel.com/en-us/articles/programming-and-compiling-for-intel-many-integrated-core-architecture下找到的文章. 这些文章是由开发和/或支持协处理器的各种编程工具的人撰写的,应该可以回答您的大部分问题。
Update: What's below does NOT answer the OP's question - it is one possible explanation for the cannot execute binary file
error, but the fact that the error message is prefixed with bash:
indicates that the binary is being invoked correctly (by bash), but is not compatible with the executing platform (compiled for a different architecture) - as @Barmar has already stated in a comment.
Thus, while the following contains some (hopefully still somewhat useful) general information, it does not address the OP's problem.
One possible reason for cannot execute binary file
is to mistakenly pass a binary (executable) file -- rather than a shell script (text file containing shell code) -- as an operand (filename argument) to bash.
The following demonstrates the problem:
bash printf # fails with '/usr/bin/printf: /usr/bin/printf: cannot execute binary file'
Note how the mistakenly passed binary's path prefixes the error message twice; If the first prefix says bash:
instead, the cause is most likely not a problem of incorrect invocation, but one of trying to a invoke an incompatible binary (compiled for a different architecture).
If you want bash to invoke a binary, you must use the -c
option to pass it, which allows you to specify an entire command line; i.e., the binary plus arguments; e.g.:
bash -c '/usr/bin/printf "%s\n" "hello"' # -> 'hello'
If you pass a mere binary filename instead of a full path - e.g., -c 'program ...'
- then a binary by that name must exist in one of the directories listed in the $PATH
variable that bash sees, otherwise you'll get a command not found
error.
If, by contrast, the binary is located in the current directory, you must prefix the filename with ./
for bash to find it; e.g. -c './program ...'