Skip to content

Segmentation Fault (SIGSEGV) when using tensorflow.keras.config.enable_unsafe_deserialization() #829

Open
@Pablo-Caballero-Maria

Description

@Pablo-Caballero-Maria

System information.

  • Have I written custom code (as opposed to using a stock example script provided in Keras): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Arch Linux 6.13.2
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.18.0
  • Python version: 3.12.9
  • Bazel version (if compiling from source):
  • GPU model and memory: Nvidia MX 130 (2Gb)
  • Exact command to reproduce:

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with:
python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"

Describe the problem.

When calling tensorflow.keras.models.load_model() after enabling tensorflow.keras.config.enable_unsafe_deserialization(), the script terminates with a segmentation fault (SIGSEGV). Additionally, the logs display sem_destroy: Success before the crash.
The reason why I post the issue in this repository is because, in order to use enable_unsafe_deserialization() from tensorflow.keras, I had to install tf-keras, so I thought the issue arises from here.

Describe the current behavior.

The script stops running and shows this log:

sem_destroy: Success
fish: Job 1, 'python prueba.py' terminated by signal SIGSEGV (Address boundary error)

Describe the expected behavior.

TensorFlow should safely load the model without causing a segmentation fault.

Contributing.

  • Do you want to contribute a PR? (yes/no): no
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):

Standalone code to reproduce the issue.

from tensorflow.keras.models import load_model
from tensorflow.keras import config
config.enable_unsafe_deserialization()
model = load_model('model.keras')

Source code / logs.

Running sudo dmesg | grep -i segfault, I get:

[ 6531.787282] python[89460]: segfault at 60 ip 00007863e831e4d9 sp 00007fff584a0090 error 4 in libpython3.12.so.1.0[31e4d9,7863e807c000+2ad000] likely on CPU 1 (core 1, socket 0)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions