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

hack default compiler option sets to fix tensorflow 1.13.1 on python 3.7 #7424

Merged
merged 3 commits into from Mar 29, 2019

Conversation

Projects
None yet
2 participants
@cosmicexplorer
Copy link
Contributor

commented Mar 22, 2019

See tensorflow/tensorflow#27078 for an upstream tensorflow issue I made asking about the cause of #7417.

Problem

Resolves #7417. tensorflow==1.13.1 uses the newer C++ ABI for the shared library in its python 3.7 wheel on Linux, contradicting their docs on how to add a new custom operator, which says that their public releases use -D_GLIBCXX_USE_CXX11_ABI=0. Instead, we have (on Linux):

> pip3 install tensorflow==1.13.1
> python3.7
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow.sysconfig as tfs
>>> dir(tfs)
['CXX11_ABI_FLAG', 'MONOLITHIC_BUILD', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'get_compile_flags', 'get_include', 'get_lib', 'get_link_flags']
>>> tfs.CXX11_ABI_FLAG
1
>>> tfs.get_compile_flags()
['-I/usr/local/lib/python3.7/dist-packages/tensorflow/include', '-D_GLIBCXX_USE_CXX11_ABI=1']

However, on OSX:

> pex --python=python3.7 tensorflow==1.13.1
Python 3.7.2 (default, Feb 14 2019, 13:28:01)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import tensorflow.sysconfig as tfs
>>> dir(tfs)
['CXX11_ABI_FLAG', 'MONOLITHIC_BUILD', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'get_compile_flags', 'get_include', 'get_lib', 'get_link_flags']
>>> tfs.CXX11_ABI_FLAG
0
>>> tfs.get_compile_flags()
['-I/private/var/folders/l_/3k9sqfqn5_z5v1zbxgrnxtyh0000gn/T/tmpgZIVDs/.deps/tensorflow-1.13.1-cp37-cp37m-macosx_10_11_x86_64.whl/tensorflow/include', '-D_GLIBCXX_USE_CXX11_ABI=0']
>>>

This is possibly unintentional on the part of TensorFlow, but it is perfectly reasonable for that project to eventually change to using the newer C++ ABI.

In this particular case, we want to use -D_GLIBCXX_USE_CXX11_ABI=1, but only when using a python 3.7 interpreter on Linux. This allows us to avoid skipping that test in python 3.7 shards in #7261.

Solution

  • Remove the explicit glibcxx_use_old_abi on our tensorflow custom C++ operator example, and make that one of the default option sets.
  • (in #7261, depending on which lands first) Remove the glibcxx_use_old_abi from the default option sets in the python 3.7 Linux shard.

Result

We don't have to skip the tensorflow testing for python 3.7 on Linux.

@cosmicexplorer cosmicexplorer requested a review from Eric-Arellano Mar 22, 2019

@Eric-Arellano
Copy link
Contributor

left a comment

Thank you for figuring this out!

Show resolved Hide resolved pants.ini Outdated

@cosmicexplorer cosmicexplorer changed the title introduce default compiler option sets to fix tensorflow 1.13 on python 3.7 hack default compiler option sets to fix tensorflow 1.13.1 on python 3.7 Mar 24, 2019

cosmicexplorer added some commits Mar 22, 2019

@cosmicexplorer cosmicexplorer force-pushed the cosmicexplorer:fix-tensorflow-py37 branch from 7354aec to 8ce641f Mar 28, 2019

@cosmicexplorer

This comment has been minimized.

Copy link
Contributor Author

commented Mar 28, 2019

This PR needs to remove the skipIf on the tensorflow example before being merged.

@Eric-Arellano
Copy link
Contributor

left a comment

Thanks for filing the upstream issue!

@cosmicexplorer cosmicexplorer merged commit e620a9e into pantsbuild:master Mar 29, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

cosmicexplorer added a commit that referenced this pull request Mar 31, 2019

Fix typo from #7424 to properly fix TensorFlow test during Python 3.7…
… cron job (#7464)

### Problem

#7424 typoed the compiler option sets env var, so didn't actually fix #7417.

### Solution

- Correct the compiler option sets env var name which tells pants to use the new C++ ABI to compile our tensorflow custom operator.

### Result

The python 3.7 cron job passes!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.