Jupyter Kernel 由于 Tensorflow 在 macOS 上崩溃

发布于 2025-01-10 04:14:47 字数 1490 浏览 0 评论 0原文

我在大学课程中使用的 Jupyter 脚本遇到了问题。有用信息:我使用的是 MacBook Air(第一次)、macOS Monterey 12.0.1、M1 Apple 芯片,并且我正在使用 conda 4.11.0 和 Python 3.9.7 的 conda 虚拟环境中工作。这是脚本的第一部分:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from tensorflow import keras   <--
import tensorflow as tf   <--
from sklearn.utils import shuffle
from sklearn import preprocessing
from keras import regularizers   <--
import random
from keras.utils.vis_utils import plot_model   <--
import time
from IPython.display import Image

当我运行它时,我收到以下消息:
内核似乎已经死亡。它会自动重新启动。

我尝试对每一行进行评论,显然,问题是由于我用箭头突出显示的行造成的。所以TensorFlow有问题。按照教授的建议,我在终端上输入 ipython,然后是这样的:

In [1]: import tensorflow
zsh: illegal hardware instruction  ipython 

我在互联网上查了一下,我了解到一些 Python 包和 M1 Apple 芯片之间存在一些不兼容性。我尝试遵循此 https://github.com/apple/tensorflow_macos,但是当我使用命令写在那里,这就是发生的事情

(phdcourse) alessandroruggieri@Alessandros-MacBook-Air ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"

ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later.

这很奇怪,考虑到我有 macOS 12.0.1(如开头所述)。
总而言之,我在互联网上看到了一些关于类似问题的帖子,但它们看起来都相当令人困惑,所以我真的很感激简单明了的帮助。

I am having trouble with a Jupyter script that I am using for a class at university. Useful information: I am using a MacBook Air (first time), macOS Monterey 12.0.1, M1 Apple chip, and I am working in a conda virtual environment with conda 4.11.0 and Python 3.9.7. This is the first part of the script:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from tensorflow import keras   <--
import tensorflow as tf   <--
from sklearn.utils import shuffle
from sklearn import preprocessing
from keras import regularizers   <--
import random
from keras.utils.vis_utils import plot_model   <--
import time
from IPython.display import Image

When I run it, I get this message:
The kernel appears to have died. It will restart automatically.

I tried commenting each row, and apparently, the problem is due to the ones that I highlighted with the arrow. So there is something wrong with TensorFlow. As suggested by my professor, I went on the terminal, typed ipython, then this:

In [1]: import tensorflow
zsh: illegal hardware instruction  ipython 

I looked it up on the internet, and I understood that there are some incompatibilities between some Python packages and the M1 Apple chip. I tried to follow this https://github.com/apple/tensorflow_macos, but when I use the command written there, this is what happens

(phdcourse) alessandroruggieri@Alessandros-MacBook-Air ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"

ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later.

This is pretty weird, considering I have macOS 12.0.1 (as said at the beginning).
To conclude, I have seen some posts about similar issues on the internet, but they all look rather confusing, so I would really appreciate an easy and clear help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文