Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault when importing SimpleITK 2.0 before TensorFlow #1208

Closed
alkamid opened this issue Sep 25, 2020 · 7 comments
Closed

Segmentation Fault when importing SimpleITK 2.0 before TensorFlow #1208

alkamid opened this issue Sep 25, 2020 · 7 comments

Comments

@alkamid
Copy link

alkamid commented Sep 25, 2020

Likely related to #1192

OS: Ubuntu 20.04
Python 3.8.2 (tested with 3.7, too)

Make a virtualenv:

python -m venv sitk_venv
source sitk_venv/bin/activate
pip install tensorflow==2.3.1 SimpleITK==2.0.0

test.py:

import SimpleITK as sitk
import tensorflow as tf
$ python test.py
Segmentation fault (core dumped)

If we reverse the order of imports (TensorFlow first), it works fine. I'm not sure whether it's an issue with TF or SimpleITK, but it doesn't happen with SimpleITK==1.2.4.

@blowekamp
Copy link
Member

Thank you for reporting this issue. We will look into it.

@blowekamp
Copy link
Member

blowekamp commented Sep 25, 2020

SimpleITK wheels are compiled per PEP 513 manylinux1, while tensor flow is manylinux2010. I believe these should be interoperable; I will need further investigation.

@blowekamp
Copy link
Member

Here is an related piece with PyArrow: https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html

Specifically the section "Annoying end users issue #2: 'Segmentation fault after import TensorFlow"' appear to be relevant.

blowekamp added a commit to blowekamp/SimpleITK that referenced this issue Sep 25, 2020
This fix is inspired but the following article and linked changes:
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html

Use a linker script make only the one global symbol needed by Python
visible, while the others remain local. This hides the weak C++/std symbol
which can conflict with other libraries. Specifically, the
std::call_once conflicting with tensorflow.

Addresses SimpleITK#1208 and SimpleITK#1192.
@ltetrel
Copy link

ltetrel commented Sep 25, 2020

I had the same issue.
Changing the import order as @alkamid suggested worked for me.

blowekamp added a commit to blowekamp/SimpleITK that referenced this issue Sep 30, 2020
This fix is inspired but the following article and link changes:
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html

Use a version linker script make only the one global symbol needed by
Python visible, while the others remain local. This hides the weak
C++/std symbol which can conflict with versions. Specifically, the
std::call_once conflicting with tensorflow.

Addresses SimpleITK#1208 and SimpleITK#1192.
blowekamp added a commit to blowekamp/SimpleITK that referenced this issue Sep 30, 2020
This fix is inspired but the following article and link changes:
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html

Use a version linker script make only the one global symbol needed by
Python visible, while the others remain local. This hides the weak
C++/std symbol which can conflict with versions. Specifically, the
std::call_once conflicting with tensorflow.

Addresses SimpleITK#1208 and SimpleITK#1192.
blowekamp added a commit to blowekamp/SimpleITK that referenced this issue Oct 2, 2020
This fix is inspired but the following article and link changes:
https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html

Use a version linker script make only the one global symbol needed by
Python visible, while the others remain local. This hides the weak
C++/std symbol which can conflict with versions. Specifically, the
std::call_once conflicting with tensorflow.

Addresses SimpleITK#1208 and SimpleITK#1192.
@blowekamp
Copy link
Member

This issue has been addressed in PR #1210 and has been merged into master. It is available in the "latest" nightly packages. Please download and test the package to verify it resolves the issue. Then it can be merged into the release branch for 2.0.1.

@alkamid
Copy link
Author

alkamid commented Oct 5, 2020

I can confirm that using this wheel (2.1.0.dev23) fixes the issue.

@blowekamp
Copy link
Member

SimpleITK 2.0.1 have been uploaded to pypi, which addresses the import order issue with tensor flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants