Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Issue for M1 Chip #1348

Open
cadyyuheng opened this issue Sep 21, 2022 · 1 comment
Open

Installation Issue for M1 Chip #1348

cadyyuheng opened this issue Sep 21, 2022 · 1 comment

Comments

@cadyyuheng
Copy link

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
@cadyyuheng
Copy link
Author

This is now resolved. After running

reticulate::miniconda_uninstall()
reticulate::install_miniconda()

The numpy version for the r-reticulate environment is 1.23.3. Yet after running

keras::install_keras()

The numpy version was downgraded to 1.22.4, which I suspect caused the error message running tensorflow::as_tensor("Hello World")

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

After I manually upgraded the numpy back to 1.23.3in r-reticulate, tensorflow::as_tensor("Hello World") gave successful output.
I wonder if the keras team could solve this issue for future updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant