Skip to content

Instantly share code, notes, and snippets.

@nathania
Forked from juliasilge/installation.md
Created February 14, 2023 18:32
Show Gist options
  • Save nathania/8750616487c3ed619fca64048394cb0f to your computer and use it in GitHub Desktop.
Save nathania/8750616487c3ed619fca64048394cb0f to your computer and use it in GitHub Desktop.
Installing R + Tensorflow on M1

Install native ARM R: https://cloud.r-project.org/

Install RStudio (probably preview) which is not native as of today: https://www.rstudio.com/products/rstudio/download/preview/

This blog post is helpful for getting Tensorflow working, but it is older, before the ARM version of R and the RStudio version that supports it was available.

This other blog post has specific steps outlined, but some of it has also been superseded.

Looks to me like Apple's instructions are the best as of today: https://developer.apple.com/metal/tensorflow-plugin/

Here is what I think you need to do:

  • Make sure you have Python 3.8 or Python 3.9
  • Install Miniforge for ARM, using reticulate::install_miniconda() from within R
  • Create conda environment for your TensorFlow install (I called it tf_env and have had better luck doing it from the command line)
  • Install packages like numpy, pandas, etc for ARM (try it with conda install -c apple tensorflow-deps from Apple's instructions? is that good enough?)
  • Install base Tensorflow (I have not tried the tensorflow-metal yet)

You can turn it on (in the terminal) with conda activate tf_env and turn it off with conda deactivate. I have this in my .Renviron:

RETICULATE_PYTHON = "~/miniforge3/envs/tf_env/bin/python"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment