Skip to content

Installation Issue for M1 Chip #1348

Open
@cadyyuheng

Description

@cadyyuheng

Hello,

Although I have read several posts on handling the "TensorFlow not found" installation issue, I am still unable to successfully install Keras. I restarted R session and installed with commands:

remotes::install_github("rstudio/tensorflow")
remotes::install_github("rstudio/keras")
reticulate::miniconda_uninstall()
reticulate::install_miniconda()
keras::install_keras()

I can find and tensorflow-macro and tensorflow-metal in r-reticulate. Yet when I try to test keras installation, I got the following error:

> tensorflow::as_tensor("Hello World")
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /Users//Library/r-miniconda-arm64/envs/r-reticulate/bin/python3.8

Python exception encountered:
 ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

SystemError: <built-in method __contains__ of dict object at 0x11f316bc0> returned a result with an error set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library

Attached is my session information and I sincerely hope you could help me with this.

> reticulate::py_config()
python:         /Users//Library/r-miniconda-arm64/envs/r-reticulate/bin/python3.8
libpython:      /Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/libpython3.8.dylib
pythonhome:     /Users//Library/r-miniconda-arm64/envs/r-reticulate:/Users//Library/r-miniconda-arm64/envs/r-reticulate
version:        3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:05:16)  [Clang 12.0.1 ]
numpy:          /Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/numpy
numpy_version:  1.22.4
tensorflow:     /Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow

NOTE: Python version was forced by use_python function
> tensorflow::tf_config()
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /Users//Library/r-miniconda-arm64/envs/r-reticulate/bin/python3.8

Python exception encountered:
 ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

SystemError: <built-in method __contains__ of dict object at 0x11f35ed80> returned a result with an error set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 37, in <module>
    from tensorflow.python.eager import context
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow/python/eager/context.py", line 35, in <module>
    from tensorflow.python.client import pywrap_tf_session
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/Users//Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages/tensorflow/python/client/pywrap_tf_session.py", line 19, in <module>
    from tensorflow.python.client._pywrap_tf_session import *
  File "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
ImportError: initialization failed


You can install TensorFlow using the install_tensorflow() function.
 
> reticulate::import("tensorflow")
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
Error in py_module_import(module, convert = convert) : 
  ImportError: initialization failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions