首页 > 解决方案 > 安装 keras 和 tensorflow 后,python 脚本因 Segmentation Fault (core dumped) 而崩溃

问题描述

在此处输入图像描述为什么导入语句(最终导致 keras 导入)仅在处理故意异常后才起作用???????

我有一个带有多个 main.py 入口点的 python3.5 项目。

一个入口点在服务器上运行,另一个在客户端上使用 pycos 进行通信(网络 IPC)。

我的 server/main.py 曾经执行得很好,但是在安装了 keras 和 tensorflow 之后

pip install -r requirements.txt --user

server/main.py 崩溃读取

Using TensorFlow backend.
Segmentation fault (core dumped)

我已经监控了服务器 VM 上的 RAM、硬盘空间,但没有任何迹象表明 server/main.py 崩溃了……它甚至没有在导入跟踪中导入 keras 或 tensorflow。我猜 _ init _.py 导入跟踪最终会导致导入 keras / tensorflow 包的模块

谁能建议如何找到问题?

要求.txt

jsonpickle
matplotlib
seaborn
numpy
pycos
jsonpickle
statsmodels
pandas
sklearn
pymongo
keras
tensorflow==2.0.0-beta1

标签: python-3.xtensorflowubuntu-16.04

解决方案


事实证明,如果调用 pycos 的 python 模块暴露在它们各自 python 子包的 _ _ init _ _.py 中,pycos 会执行一个底层调度程序,该调度程序会以某种方式干扰 Tensorflow(导致 seg 错误)。

删除 monitoringSimulation/monitor.py 等。从 monitoringSimulation/ _ _ init _ _.py 导入解决了这个问题。

将向 pycos 提交一个错误,因为我最终需要将 monitor.py 模块暴露给其他子包。


推荐阅读