io icon indicating copy to clipboard operation
io copied to clipboard

`NotImplementedError: unable to open file: libtensorflow_io.so` with `tensorflow==2.8.0` and `tensorflow-io==0.24.0`

Open dschwertfeger opened this issue 2 years ago • 3 comments

On macOS 10.15.7, in a fresh virtual environment with only tensorflow==2.8.0, tensorflow-io==0.24.0 and ipython installed, I'm getting this NotImplementedError:

NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']
    caused by: ['dlopen(/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so, 6): Library not loaded: /System/Library/Frameworks/AVFAudio.framework/Versions/A/AVFAudio\n  Referenced from: /Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so\n  Reason: image not found']

...when trying to call audio_ops.resample():

import tensorflow as tf
import tensorflow_io as tfio
x = tf.zeros((2, 16000))
tfio.audio.resample(x, 16000, 8000, name=None)

Apparently, the C++ core_ops can't be loaded in _load_library.

Downgrading to tensorflow==2.7.1 and tensorflow-io==0.23.1 resolves this issue.

Full traceback
In [1]: import tensorflow_io as tfio
   ...: import tensorflow as tf
   ...: x = tf.zeros((2, 16000))
   ...: tfio.audio.resample(
   ...:     x, 16000, 8000, name=None
   ...: )
2022-03-17 19:14:17.763749: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Input In [1], in <cell line: 4>()
      2 import tensorflow as tf
      3 x = tf.zeros((2, 16000))
----> 4 tfio.audio.resample(
      5     x, 16000, 8000, name=None
      6 )
File ~/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/audio_ops.py:462, in resample(input, rate_in, rate_out, name)
    457 def f(i):
    458     return core_ops.io_audio_resample(
    459         i, rate_in=rate_in, rate_out=rate_out, name=name
    460     )
--> 462 value = tf.vectorized_map(f, input)
    464 def g1():
    465     return tf.squeeze(value, [0, -1])

File ~/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py:544, in vectorized_map(fn, elems, fallback_to_while_loop)
    541 else:
    542   batch_size = max(static_first_dims)
--> 544 return pfor(loop_fn, batch_size,
    545             fallback_to_while_loop=fallback_to_while_loop)

File ~/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py:202, in pfor(loop_fn, iters, fallback_to_while_loop, parallel_iterations)
    200     def_function.run_functions_eagerly(False)
    201   f = def_function.function(f)
--> 202 outputs = f()
    203 if functions_run_eagerly is not None:
    204   def_function.run_functions_eagerly(functions_run_eagerly)

File ~/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    151 except Exception as e:
    152   filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153   raise e.with_traceback(filtered_tb) from None
    154 finally:
    155   del filtered_tb

File ~/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py:1147, in func_graph_from_py_func.<locals>.autograph_handler(*args, **kwargs)
   1145 except Exception as e:  # pylint:disable=broad-except
   1146   if hasattr(e, "ag_error_metadata"):
-> 1147     raise e.ag_error_metadata.to_exception(e)
   1148   else:
   1149     raise

NotImplementedError: in user code:

    File "/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/audio_ops.py", line 458, in f
        return core_ops.io_audio_resample(
    File "/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/__init__.py", line 88, in __getattr__
        return getattr(self._load(), attrb)
    File "/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/__init__.py", line 84, in _load
        self._mod = _load_library(self._library)
    File "/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/__init__.py", line 69, in _load_library
        raise NotImplementedError(

    NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']
    caused by: ['dlopen(/Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so, 6): Library not loaded: /System/Library/Frameworks/AVFAudio.framework/Versions/A/AVFAudio\n  Referenced from: /Users/dsc/.pyenv/versions/3.9.6/envs/tftfio/lib/python3.9/site-packages/tensorflow_io/python/ops/libtensorflow_io.so\n  Reason: image not found']

dschwertfeger avatar Mar 18 '22 14:03 dschwertfeger

Faced with the same issue here. My reproduce codes are:

import  tensorflow_io as tfio
import os

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
short = tfio.audio.AudioIOTensor('Data/demo.mav')
print(short)

The error is

NotImplementedError: unable to open file: libtensorflow_io.so, from paths: [my miniforge3/python/site-packages/...]

DummyPuppy avatar Jun 10 '22 15:06 DummyPuppy

Downgrading to tensorflow==2.8.0 and tensorflow-io==0.25.0 works for me on Windows 11 Native.

AhmetEkiz avatar Mar 05 '23 10:03 AhmetEkiz