1

I have a huge problem creating a conda environment with the new Tensorflow 2.5 optimized for M1 (Macbook pro-2020).

I followed those steps:

  1. install miniforge3 optimized for arm64 processor from https://github.com/conda-forge/miniforge
  2. then create a conda env on the terminal ("conda create --name tf25" and "conda activate tf25")
  3. After I followed the apple guide (https://developer.apple.com/metal/tensorflow-plugin/)

This is the result:

enter image description here

In the end, when I try to import the NumPy package there is an import error.

import numpy

Traceback (most recent call last): File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/init.py", line 22, in from . import multiarray File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in from . import overrides File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: dlopen(/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/init.py", line 140, in from . import core File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/init.py", line 48, in 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/antoniosquicciarini/miniforge3/envs/tf25/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/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so

Reason: image not found

I already tried to:

  • Install numpy with pip
  • Install a lower version of python (3.8)

I think there is a compatibility problem with the new TensorFlow an NumPy library, because until today I used the TensorFlow 2.4 in another conda env

2
  • Follow the instructions mentioned on official website to install Tensorflow on Mac tensorflow.org/install/pip#macos Commented Sep 10, 2021 at 13:31
  • I have the same problem. The official website does not really help. If you have a fix, please let me know. Commented Oct 21, 2021 at 14:35

1 Answer 1

6

The answer was posted here

Original error was: dlopen(/Users/ulto4/miniforge3/envs/python386/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 2):

You need to install openblas:

conda install -c conda-forge openblas

This fixed the error and numpy works.

Sign up to request clarification or add additional context in comments.

2 Comments

My god. I have had two days of pain trying to install tensorflow onto my M1 pro. Your comment saved me. Thank you. For other people having pain. I used this to tutorial to start: caffeinedev.medium.com/… After numerous other random problems that could not be solved, I restarted my laptop. This was my last problem and now it works. @EnergyNet is my hero.
This answers also solved my issue on M1 Mac as well, after I installed the tensorflow-macso with conda.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.