tensorflow / io

Dataset, streaming, and file system extensions maintained by TensorFlow SIG-IO
Apache License 2.0
702 stars 283 forks source link

Importing tensorflow_io leads AttributeError: module 'tensorflow._api.v2.experimental' has no attribute 'register_filesystem_plugin' #1306

Open caubekimo opened 3 years ago

caubekimo commented 3 years ago

Describe the bug: just import modules bellow

import tensorflow as tf
import tensorflow_io as tfio

and the Traceback is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-114-c3502d6cd3c0> in <module>
      1 # Helper libraries
      2 import tensorflow as tf
----> 3 import tensorflow_io as tfio
      4 # import numpy as np
      5 # import matplotlib.pyplot as plt

/opt/conda/envs/rapids/lib/python3.7/site-packages/tensorflow_io/__init__.py in <module>
     15 """tensorflow_io"""
     16 
---> 17 from tensorflow_io.core.python.api.v0 import *  # pylint: disable=wildcard-import
     18 from tensorflow_io.core.python.api.version import VERSION as __version__
     19 

/opt/conda/envs/rapids/lib/python3.7/site-packages/tensorflow_io/core/python/api/v0/__init__.py in <module>
     16 
     17 # tensorflow_io.core.python.ops is implicitly imported (along with file system)
---> 18 from tensorflow_io.core.python.ops.io_dataset import IODataset
     19 from tensorflow_io.core.python.ops.io_tensor import IOTensor
     20 

/opt/conda/envs/rapids/lib/python3.7/site-packages/tensorflow_io/core/python/ops/__init__.py in <module>
     93 core_ops = LazyLoader("core_ops", "libtensorflow_io.so")
     94 try:
---> 95     plugin_ops = _load_library("libtensorflow_io_plugins.so", "fs")
     96 except NotImplementedError as e:
     97     # Note: load libtensorflow_io.so imperatively in case of statically linking

/opt/conda/envs/rapids/lib/python3.7/site-packages/tensorflow_io/core/python/ops/__init__.py in _load_library(filename, lib)
     61     for f in filenames:
     62         try:
---> 63             l = load_fn(f)
     64             if l is not None:
     65                 return l

/opt/conda/envs/rapids/lib/python3.7/site-packages/tensorflow_io/core/python/ops/__init__.py in <lambda>(f)
     53         load_fn = lambda f: ctypes.CDLL(f, mode=ctypes.RTLD_GLOBAL)
     54     elif lib == "fs":
---> 55         load_fn = lambda f: tf.experimental.register_filesystem_plugin(f) is None
     56     else:
     57         load_fn = lambda f: tf.compat.v1.load_file_system_library(f) is None

AttributeError: module 'tensorflow._api.v2.experimental' has no attribute 'register_filesystem_plugin'

Environment details: Environment location: Docker 20.10.2

Docker image: rapidsai/rapidsai:latest

Linux Distro/Architecture: Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-142-generic x86_64)

GPU Model/Driver: GeForce RTX 2080Ti * 4 and driver 418.39

CUDA: 10.1

Tensorflow packages: tensorboard 2.4.0 tensorboard-plugin-wit 1.7.0 tensorflow 2.4.1 tensorflow-datasets 4.2.0 tensorflow-estimator 2.4.0 tensorflow-hub 0.11.0 tensorflow-io 0.17.0 tensorflow-metadata 0.27.0

is this a bug or something I am doing wrong?

yongtang commented 3 years ago

@caubekimo Can you show the steps you used to install python, tensorflow, tensorflow-io?

I am not familiar with rapidsai's docker image. When I give it a try, the tensorflow is not installed:

$ docker run -i -t --net=host rapidsai/rapidsai:latest
A JupyterLab server has been started!
To access it, visit http://localhost:8888 on your host machine.
Ensure the following arguments were added to "docker run" to expose the JupyterLab server to your host machine:
      -p 8888:8888 -p 8787:8787 -p 8786:8786
Make local folders visible by bind mounting to /rapids/notebooks/host
(rapids) root@ip-172-31-87-192:/rapids# python3
Python 3.7.8 | packaged by conda-forge | (default, Nov 17 2020, 23:45:15) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>> 

Can you show the steps you used to install tensorflow and tensorflow-io?

caubekimo commented 3 years ago

Can you show the steps you used to install tensorflow and tensorflow-io?

Sure, I install it with the most easy way:

pip install tensorflow
pip install tensorflow-io

thanks for the try.

ddogfoodd commented 3 years ago

@caubekimo Hey I also installed both via pip and got the same error while using tensorflow 2.3.0, however on another machine that was running tensorflow 2.5.0 I was able to import tensorflow_io. Maybe try to upgrade tensorflow (eg. by pip install -U tensorflow).

EDIT: Another thing that worked for me was using an older realease of tensorflow-io. I use tensorflow 2.3.0 and downgraded tensorflow-io to 0.16.0 (pip install -U tensorflow-io==0.16.0) and was then able to import it.

caubekimo commented 3 years ago

@caubekimo Hey I also installed both via pip and got the same error while using tensorflow 2.3.0, however on another machine that was running tensorflow 2.5.0 I was able to import tensorflow_io. Maybe try to upgrade tensorflow (eg. by pip install -U tensorflow).

EDIT: Another thing that worked for me was using an older realease of tensorflow-io. I use tensorflow 2.3.0 and downgraded tensorflow-io to 0.16.0 (pip install -U tensorflow-io==0.16.0) and was then able to import it.

Hi @jalemann , thank you for your relply, it seems to be the version conflict, but i don't know which package.

I shall try your finding, thank you so much~