Skip to content

import tf-io failed when using custom tf wheel #1240

Closed

Description

@vnghia

I've built a custom tf wheel (OS: Ubuntu 20.10, commit tensorflow/tensorflow@b19ef9b) with --config=noaws --config=nogcp --config=nohdfs --config=nonccl ( basically no boringssl, curl stuff and no filesystem ). When I tried to import tf-io ( both nightly and 0.17 ), I got this error

Traceback (most recent call last):
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 95, in <module>
    plugin_ops = _load_library("libtensorflow_io_plugins.so", "fs")
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 68, in _load_library
    raise NotImplementedError(
NotImplementedError: unable to open file: libtensorflow_io_plugins.so, from paths: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io_plugins.so']
caused by: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io_plugins.so: undefined symbol: curl_easy_cleanup']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/__init__.py", line 17, in <module>
    from tensorflow_io.core.python.api.v0 import *  # pylint: disable=wildcard-import
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/api/v0/__init__.py", line 18, in <module>
    from tensorflow_io.core.python.ops.io_dataset import IODataset
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 98, in <module>
    core_ops = _load_library("libtensorflow_io.so")
  File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 68, in _load_library
    raise NotImplementedError(
NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so']
caused by: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so: undefined symbol: _ZNK10tensorflow4data15DatasetOpKernel11TraceStringERKNS_15OpKernelContextEb']

I think there are some ODR violations. I think tensorflow are trying to use it own symbols or tensorflow_io accidentally calls the symbols from tensorflow ( so when there is a full wheel, we don't see any error ). Though I am not sure if I have to use that custom wheel to rebuild tensorflow-io or it should work with any wheel.

@yongtang Could you help me with this issue ? Thank you !

Activity

  1. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    When importing 0.16, it throws:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/__init__.py", line 17, in <module>
        from tensorflow_io.core.python.api.v0 import *  # pylint: disable=wildcard-import
      File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/api/v0/__init__.py", line 18, in <module>
        from tensorflow_io.core.python.ops.io_dataset import IODataset
      File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 71, in <module>
        core_ops = _load_library("libtensorflow_io.so")
      File "/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 65, in _load_library
        raise NotImplementedError(
    NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so']
    caused by: ['/home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so: undefined symbol: _ZN10tensorflow4data15DatasetOpKernel11TraceStringEPNS_15OpKernelContextEb']
    
  2. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    Inside /home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow, I found a folder include/external/aws/, it there any chance that tensorflow_io uses these headers instead of its own ?

  3. yongtang commented on Dec 21, 2020

    @yongtang
    Member

    @vnvo2409 Which version of the tensorflow are you using to build customized wheels? The tensorflow-io needs to match specific version of tensorflow for C++ API compatibility, i.e., tensorflow-io 0.16.0 matches TF 2.3.0 and tensorflow-io 0.17.0 matches TF 2.4.0 (for C++ API).

    For _ZN10tensorflow4data15DatasetOpKernel11TraceStringEPNS_15OpKernelContextEb, I am almost sure this is caused by C++ incompatibility so a version match should fix the issue.

    For curl_easy_cleanup I think this is caused by symbols leaked from tensorflow to tensorflow-io.

  4. yongtang commented on Dec 21, 2020

    @yongtang
    Member

    Inside /home/vovannghia2409/programming/.venvs/tf-mini/lib/python3.8/site-packages/tensorflow, I found a folder include/external/aws/, it there any chance that tensorflow_io uses these headers instead of its own ?

    @vnvo2409 This is very much a concern. In the past we count on using the same version of third-party libraries to avoid issues. Apparently this is causing big problems when AWS C++ SDK does not match.

  5. yongtang commented on Dec 21, 2020

    @yongtang
    Member

    @vnvo2409 Some of the header files are capture in the following I believe.
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/pip_package/build_pip_package.sh

    I will take a look and see if we could remove AWS from the header files in tensorflow.

  6. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    Which version of the tensorflow are you using to build customized wheels?

    I think it is Tensorflow 2.5. ( I build with master cause I have the cache already. If I switch into another commit, it will take me half a day. )

  7. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    I will take a look and see if we could remove AWS from the header files in tensorflow.

    @yongtang

    I think we could use --config=noaws for that thing. I think the right thing we should do right now is rebuilding tensorflow-io with a Tensorflow wheel without filesystem stuff to see if it success or not.

  8. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    For _ZN10tensorflow4data15DatasetOpKernel11TraceStringEPNS_15OpKernelContextEb, I am almost sure this is caused by C++ incompatibility so a version match should fix the issue.

    @yongtang

    Related to this issue, If I build libtensorflow_io_plugins.so and load it into tensorflow using tf.experimental.register_filesystem_plugin, it throws

    tensorflow.python.framework.errors_impl.NotFoundError: /home/vovannghia2409/.cache/bazel/_bazel_vovannghia2409/12a622ca2d44c6042e6788ef08cb9901/execroot/org_tensorflow_io/bazel-out/k8-dbg/bin/tensorflow_io/core/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZTVN3Aws8External8tinyxml210XMLPrinterE
    

    which makes me think that it use the symbol from TensorFlow core instead of Tensorflow_io because we should not have any mismatch here.

  9. vnghia commented on Dec 21, 2020

    @vnghia
    ContributorAuthor

    @yongtang

    If I use the customized wheel to rebuild libtensorflow_io_plugins.so, the segfault goes away.

  10. yongtang commented on Dec 21, 2020

    @yongtang
    Member

    @vnvo2409 I created a PR #1241 to remove tensorflow's AWS header file from exposing. Can you give it a try and see if that will resolve the issue without a custom tensorflow wheel?

  11. vnghia commented on Dec 22, 2020

    @vnghia
    ContributorAuthor

    For _ZN10tensorflow4data15DatasetOpKernel11TraceStringEPNS_15OpKernelContextEb, I am almost sure this is caused by C++ incompatibility so a version match should fix the issue.

    @yongtang One more thought about it. As far as I understand, libtensorflow_io_plugins.so should work with all TensorFlow wheel. I think it is the ultimate goal of my GSoC project.

    But tensorflow_io works only with specific TensorFlow wheel and we can't use libtensorflow_io_plugins.so without importing tensorflow_io. Does it defeat the purpose of the C API of the Modular Filesystem ?

    Is there a way we could separate the filesystems with tensorflow_io ? Maybe another pip package like tensorflow_filesystem ?

  12. yongtang commented on Dec 22, 2020

    @yongtang
    Member

    @vnvo2409 When import tensorflow_io as tfio is called, only libtensorflow_io_plugins.so is loaded. The libtensorflow_io.so will not be loaded until it is actually used. You can see PR #1208 for details.

  13. vnghia commented on Dec 22, 2020

    @vnghia
    ContributorAuthor

    @yongtang Thank you! In my case, the loading of libtensorflow_io_plugins.so failed, so it fell back to the loading of libtensorflow_io.so.

  14. vnghia commented on Jun 6, 2021

    @vnghia
    ContributorAuthor

    Close since this is resolved by #1426.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions