为什么在 Mac 上加载 tensorflow 会导致“进程完成,退出代码为 132(被信号 4:SIGILL 中断)"? [英] Why does loading tensorflow on Mac lead to "Process finished with exit code 132 (interrupted by signal 4: SIGILL)"?

查看:81
本文介绍了为什么在 Mac 上加载 tensorflow 会导致“进程完成,退出代码为 132(被信号 4:SIGILL 中断)"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是配备 M1 处理器的 MacBook Pro,macOS 版本 11.0.1,PyCharm 中的 Python 3.8,Tensorflow 版本 2.4.0rc4(也尝试过 2.3.0、2.3.1、2.4.0rc0).我正在尝试运行以下代码:

I am using a MacBook Pro with M1 processor, macOS version 11.0.1, Python 3.8 in PyCharm, Tensorflow version 2.4.0rc4 (also tried 2.3.0, 2.3.1, 2.4.0rc0). I am trying to run the following code:

import tensorflow

这会导致错误消息:

Process finished with exit code 132 (interrupted by signal 4: SIGILL)

代码在我的 Windows 和 Linux 机器上运行良好.错误消息是什么意思,我该如何解决?

The code runs fine on my Windows and Linux machines. What does the error message mean and how can I fix it?

推荐答案

似乎当你安装了多个 python 解释器时会出现这个问题,其中一些是针对不同的架构师(x86_64 vs arm64).您需要确保使用了正确的 python 解释器,如果您安装了 Apple 的 tensorflow 版本,那么可能需要一个 arm64 解释器.

Seems that this problem happens when you have multiple python interpreters installed, and some of them are for differente architectuers (x86_64 vs arm64). You need to make sure that the correct python interpreter is being used, if you installed Apple's version of tensorflow, then that probably requires an arm64 interpreter.

如果你使用 rosetta(苹果的 x86_64 模拟器),那么你需要使用 x86_64 python 解释器,如果你以某种方式加载 arm64 python 解释器,你会得到非法指令错误(这是完全有道理的).

If you use rosetta (Apple's x86_64 emulator) then you need to use a x86_64 python interpreter, if you somehow load the arm64 python interpreter, you will get the illegal instruction error (which totally makes sense).

如果您使用任何安装新 Python 解释器的脚本,那么您需要确保安装了适合该架构的正确解释器(很可能是 arm64).

If you use any script that installs new python interpreters, then you need to make sure the correct interpreter for the architecture is installed (most likely arm64).

总的来说,我认为这个问题的发生是因为 python 环境设置不是为可以运行多个指令集/架构的系统设置的,pip 确实检查包的架构和主机系统,但似乎你可以运行一个 x86_64 解释器来加载一个用于 arm64 的包,这会产生问题.

Overalll I think this problem happens because the python environment setup is not made for systems that can run multiple instruction sets/architectures, pip does check the architecture of packages and the host system but seems you can run a x86_64 interpreter to load a package meant for arm64 and this produces the problem.

作为参考,tensorflow_macos 中有一个问题人们可以检查.

For reference there is an issue in tensorflow_macos that people can check.

这篇关于为什么在 Mac 上加载 tensorflow 会导致“进程完成,退出代码为 132(被信号 4:SIGILL 中断)"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆