Wrong version from install_keras() and install_tensorflow()
shokru opened this issue · 3 comments
I'm trying to install versions 2.9 of both keras & tensorflow for my M1 Mac because the most recent ones generate bugs in the learning process (when calling fit()).
I tried to specify the version in the dedicated argument (version = "2.9" or version = "2.9.0"), but the function still installed the 2.12 version, which I checked by looking at /Users/MYUSERNAME/Library/r-miniconda-arm64/envs/r-reticulate/lib/python3.8/site-packages
Any idea why this occurs and how to fix it?
Thank you!
PS: I also installed the actual Python versions and copy-pasted them to replace the ones I got from R. But I then got an error message upon keras_model_sequential(): "Error: Valid installation of TensorFlow not found"... so I'm still struggling.
Installing older versions of tensorflow-macos
on M1 Macs is surprisingly difficult, and if you've updated to Ventura already, rolling back to TF 2.9 might not even work.
This request is somewhat off the beaten path, you may want to do this manually outside of R, in the terminal.
E.g., in a terminal (crucially, one where a different miniconda installation's hooks haven't been run)
source /Users/$USER/Library/r-miniconda-arm64/bin/activate
conda create --yes --name r-tensorflow
conda activate r-tensorflow
# modify the lines below to install specific versions of packages
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
Then in R you could use the created conda env with
use_condaenv("r-tensorflow")
This link might be helpful:
https://developer.apple.com/metal/tensorflow-plugin/
The apple dev link: not useful.
Your code: very useful. It worked!
Nevertheless, is there any intent (on Apple's or Google's side) to make things easier in the long term?
Clearly, this is painful for more than a handful of Mac + TF/Keras-users.
I think the intent is there, I'm sure what the timeline is however.
You may want to subscribe to tensorflow/tensorflow#11085