The Kernel crashed while executing code in the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click here for more info.
View Jupyter log for further details.
从日志中可以看出,内核崩溃的原因是由于OpenMP运行时库libiomp5md.dll的多次初始化。这通常是因为多个OpenMP运行时库被链接到程序中,这可能会导致性能下降或不正确的结果。
以下是一些可能的解决方案:
更新库:确保所有相关的Python库(如torch、numpy等)都是最新版本。有时,库的更新会解决兼容性问题。
设置环境变量:虽然不推荐,但你可以尝试设置环境变量KMP_DUPLICATE_LIB_OK=TRUE来暂时解决这个问题。请注意,这可能会导致程序崩溃或产生不正确的结果。
在Windows上,你可以在命令提示符中运行以下命令:
import os
# 设置环境变量
os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'