I have followed all the instructions to install tensorflow for my M1 mac from "https://developer.apple.com/metal/tensorflow-plugin/". Despite of showing a successful installation, there is an error when I am trying to import the tensorflow library.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import tensorflow as tf
2 tf.__version__
File ~/.local/lib/python3.9/site-packages/tensorflow/__init__.py:37, in <module>
34 import sys as _sys
35 import typing as _typing
---> 37 from tensorflow.python.tools import module_util as _module_util
38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
40 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import.
File ~/.local/lib/python3.9/site-packages/tensorflow/python/__init__.py:36, in <module>
27 import traceback
29 # We aim to keep this file minimal and ideally remove completely.
30 # If you are adding a new file with @tf_export decorators,
31 # import it in modules_with_exports.py instead.
32
33 # go/tf-wildcard-import
34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
37 from tensorflow.python.eager import context
39 # pylint: enable=wildcard-import
40
41 # Bring in subpackages.
File ~/.local/lib/python3.9/site-packages/tensorflow/python/pywrap_tensorflow.py:24, in <module>
21 from tensorflow.python.platform import self_check
23 # Perform pre-load sanity checks in order to produce a more actionable error.
---> 24 self_check.preload_check()
26 # pylint: disable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
28 try:
29 # This import is expected to fail if there is an explicit shared object
30 # dependency (with_framework_lib=true), since we do not need RTLD_GLOBAL.
File ~/.local/lib/python3.9/site-packages/tensorflow/python/platform/self_check.py:65, in preload_check()
58 else:
59 # Load a library that performs CPU feature guard checking as a part of its
60 # static initialization. Doing this here as a preload check makes it more
61 # likely that we detect any CPU feature incompatibilities before we trigger
62 # them (which would typically result in SIGILL).
63 cpu_feature_guard_library = os.path.join(
64 os.path.dirname(__file__), "../../core/platform/_cpu_feature_guard.so")
---> 65 ctypes.CDLL(cpu_feature_guard_library)
File ~/miniforge3/envs/tfm1/lib/python3.9/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
371 self._FuncPtr = _FuncPtr
373 if handle is None:
--> 374 self._handle = _dlopen(self._name, mode)
375 else:
376 self._handle = handle
OSError: dlopen(/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so, 0x0006): tried: '/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/core/platform/_cpu_feature_guard.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I have tried stack-overflow but non of the solutions worked. Please help me resolve the issue.