Symbol not found error while importing tensorflow in M1 Macbook Pro

Hello there, I have installed tensorflow in my M1 Macbook Pro using these commands in a conda environment:

  1. conda install -c apple tensorflow-deps
  2. python -m pip install tensorflow-macos
  3. python -m pip install tensorflow-metal
  4. python -m pip install tensorflow-datasets
  5. conda install jupyter pandas numpy matplotlib scikit-learn

I did it following this instruction - https://github.com/mrdbourke/m1-machine-learning-test

But when I import the packages I installed it gives me an error message.

Here:

import numpy as np
import pandas as pd
import sklearn
import tensorflow as tf
import matplotlib.pyplot as plt

# Check for TensorFlow GPU access
print(f"TensorFlow has access to the following devices:\n{tf.config.list_physical_devices()}")

# See TensorFlow version
print(f"TensorFlow version: {tf.__version__}")

Error:

---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
Input In [1], in <cell line: 4>()
      2 import pandas as pd
      3 import sklearn
----> 4 import tensorflow as tf
      5 import matplotlib.pyplot as plt
      7 # Check for TensorFlow GPU access

File ~/miniforge3/lib/python3.9/site-packages/tensorflow/__init__.py:443, in <module>
    441 _plugin_dir = _os.path.join(_s, 'tensorflow-plugins')
    442 if _os.path.exists(_plugin_dir):
--> 443   _ll.load_library(_plugin_dir)
    444   # Load Pluggable Device Library
    445   _ll.load_pluggable_device_library(_plugin_dir)

File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/load_library.py:151, in load_library(library_location)
    148     kernel_libraries = [library_location]
    150   for lib in kernel_libraries:
--> 151     py_tf.TF_LoadLibrary(lib)
    153 else:
    154   raise OSError(
    155       errno.ENOENT,
    156       'The file or folder to load kernel libraries from does not exist.',
    157       library_location)

NotFoundError: dlopen(/Users/arannya/miniforge3/lib/python3.9/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 6): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
  Referenced from: /Users/arannya/miniforge3/lib/python3.9/site-packages/tensorflow-plugins/libmetal_plugin.dylib (which was built for Mac OS X 12.3)
  Expected in: /usr/lib/libc++.1.dylib

Please help me solve this issue. I have to make a robot for a competition. So I gotta run TensorFlow.

Accepted Reply

Maybe your macOS version is not compatible? You need at least macOS 12.0+. https://developer.apple.com/metal/tensorflow-plugin/

I'm using 12.4 and no issue importing tensorflow.

  • So there's no way I can run TensorFlow in Big Sur 11.6?

Add a Comment

Replies

Maybe your macOS version is not compatible? You need at least macOS 12.0+. https://developer.apple.com/metal/tensorflow-plugin/

I'm using 12.4 and no issue importing tensorflow.

  • So there's no way I can run TensorFlow in Big Sur 11.6?

Add a Comment