I'm having trouble installing tensorflow on my M1 (2020 M1 Macbook Pro), running OS 12.1.
I'm following the instructions here. I've attempted several permutations of python version and TF version, but for this run my specific commands are
conda create -n tf_m1 python=3.9
conda activate tf_m1
conda install -c apple tensorflow-deps==2.7.0
python -m pip install tensorflow-macos==2.7.0
python -m pip install tensorflow-metal
No errors so far. Then if I run python
and import tensorflow
, I get an error (full text below). It seems to boil down to a no-such-file error for '<path/to/env>/lib/libcblas.3.dylib'. That file does exist, but it's a link to libopenblas_vortexp-r0.3.17.dylib
, which does not exist.
FWIW, I get the same error if I just try to import numpy. I can get a working numpy install with version 1.20, but not 1.19, which TF appparently requires.
This issue describes a similar error. They resolved it by uninstalling/reinstalling numpy, but that did not work for me. Any ideas?
Here's the full error text.
Python 3.9.7 (default, Sep 16 2021, 23:53:23)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: dlopen(/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib
Referenced from: /Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so
Reason: tried: '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/bin/../lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 41, in <module>
from tensorflow.python.eager import context
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 30, in <module>
import numpy as np
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/__init__.py", line 140, in <module>
from . import core
File "/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/Users/jeremy/miniforge3/envs/tf_m1/bin/python"
* The NumPy version is: "1.19.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib
Referenced from: /Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so
Reason: tried: '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/bin/../lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/lib/libcblas.3.dylib' (no such file), '/Users/jeremy/miniforge3/envs/tf_m1/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)