如何在执行tensorflow .fit时修复死内核

Mic*_*kii 7 miniconda jupyter tensorflow

执行时内核已死model.fit(train_generator,epochs=20),但相同的代码在另一台电脑上可以运行。

这是一个 Juputer 日志:

警告 17:03:05:等待单元格完成时出错 [错误:在回复完成之前取消了执行请求消息的未来

at t.KernelShellFutureHandler.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1204175)
at c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1223227
at Map.forEach (<anonymous>)
at v._clearKernelState (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1223212)
at v.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1216694)
at c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:533674
at t.swallowExceptions (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:913059)
at dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:533652)
at t.RawSession.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:537330)
at processTicksAndRejections (node:internal/process/task_queues:96:5)]
Run Code Online (Sandbox Code Playgroud)

警告 17:03:05:单元格已完成,但有错误 [错误:在回复完成之前取消了执行请求消息的未来

at t.KernelShellFutureHandler.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1204175)
at c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1223227
at Map.forEach (<anonymous>)
at v._clearKernelState (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1223212)
at v.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:1216694)
at c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:533674
at t.swallowExceptions (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:913059)
at dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:533652)
at t.RawSession.dispose (c:\Users\ivanf\.vscode\extensions\ms-toolsai.jupyter-2022.3.1000901801\out\extension.js:2:537330)
at processTicksAndRejections (node:internal/process/task_queues:96:5)]
Run Code Online (Sandbox Code Playgroud)

小智 6

内核死掉的原因有很多。但最常见的原因是内存。

您可以减少批量大小,这可能对您的计算机有所帮助。

或者尝试使用 .py 而不是 jupyter 笔记本

参考: https: //github.com/tensorflow/tensorflow/issues/9829