报错:Kernel Restarting The kernel for Untitled.ipynb appears to have died. It will restart automatical

文章讲述了在M1芯片上安装TensorFlow后,用户在notebook中遇到的问题,如GPU识别错误和KernelRestarting,原因是可能使用的安装教程过时。作者推荐使用最新版本的安装方法,如MacOS上的Miniforge安装教程。

你参考其他人的文章,安装好M1版本的TensorFlow环境后,使用notebook出现了一些问题。

import tensorflow as tf
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"
tf.compat.v1.disable_eager_execution()
hello=tf.constant('Hello,TensorFlow')
config=tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.9
sess=tf.compat.v1.Session(config=config)
print(sess.run(hello))

执行后,提示:

b'Hello,TensorFlow'
2024-01-08 16:05:50.503566: I metal_plugin/src/device/metal_device.cc:1154] Metal device set to: Apple M1 Max
2024-01-08 16:05:50.503598: I metal_plugin/src/device/metal_device.cc:296] systemMemory: 64.00 GB
2024-01-08 16:05:50.503603: I metal_plugin/src/device/metal_device.cc:313] maxCacheSize: 24.00 GB
2024-01-08 16:05:50.503654: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2024-01-08 16:05:50.503691: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
2024-01-08 16:05:50.505344: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled

核心信息为:
2024-01-08 16:05:50.503566: I metal_plugin/src/device/metal_device.cc:1154] Metal device set to: Apple M1 Max
2024-01-08 16:05:50.503654: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2024-01-08 16:05:50.503691: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: )
2024-01-08 16:05:50.505344: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled

出现则表示安装成功了。

同样,你可以直接在终端中执行以下命令:

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

出现以下内容,表示成功:
在这里插入图片描述
但是,如果使用TensorFlow过程中,notebook弹框显示:

Kernel Restarting
The kernel for Untitled.ipynb appears to have died. It will restart automatically.

这确实是个问题!

最后正确解决的办法是重新装TensorFlow。

其实,你在网上找教程,可能找到的是旧版本的安装教程!

所以导致你安装错误了,而目前我最新的版本是2.15.0,正确的安装方式请查看我的另外一篇文章:MacOS安装Miniforge、Tensorflow、Jupyter Lab等(2024年最新)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邵奈一

教育是一生的事业。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值