内核重新启动 Untitled2.ipynb 的内核似乎已死亡。存储tflite模型时会自动重启

问题描述 投票:0回答:2

我正在使用 ml.g4dn.xlarge 实例在 sagemaker 实例上运行笔记本。

我正在尝试创建如下所示的 tflite 模型

保存模型

model.save(os.path.join(model_dir, 'model.h5'))

# Convert and save the model as TensorFlow Lite
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.experimental_new_converter = True  # Enable MLIR-based conversion flow
converter.debug_info = True  # Enable the generation of a debug .mlir file
tflite_model = converter.convert()

with open(os.path.join(model_dir, 'model.tflite'), 'wb') as f:
    f.write(tflite_model)

我收到错误

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

我检查了几个要求升级实例类型的链接。我将其升级到 ml.g4dn.xlarge 但仍然给出相同的错误。有什么建议可能是什么原因吗?

tensorflow machine-learning amazon-sagemaker tflite
2个回答
0
投票

根据提供的信息,实例在转换过程中似乎内存不足。

您可以通过 JupyterLab UI(请参阅 example here)或在终端中运行

free -m
来监控当前内存消耗。

除了使用附加更多内存的实例(例如ml.g4dn.2xlarge)之外,您还可以尝试在不启用调试信息的情况下运行转换,或者您可以查看训练后量化以减小模型大小。


0
投票

正文必须至少 30 个字符;您输入了 1。

© www.soinside.com 2019 - 2024. All rights reserved.