Jupyter Kernel 由于 Tensorflow 在 macOS 上崩溃
我在大学课程中使用的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论