Search code examples
rtensorflowgcp-ai-platform-notebook

Install TensorFlow on R


Trying to install TensorFlow via install_tensorflow in Google Cloud AI Platform notebooks using R kernel:

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          6.1                         
year           2019                        
month          07                          
day            05                          
svn rev        76782                       
language       R                           
version.string R version 3.6.1 (2019-07-05)
nickname       Action of the Toes

I run:

install.packages(c("tfestimators", "tfdatasets", "cloudml", "rjson"))
library(tfestimators) # used for creating tensorflow estimators
library(tfdatasets) # used for creating data input functions
library(cloudml) # used for training and deploying models to AI Platform
install_tensorflow()

I get:

Error in virtualenv_install(envname, packages, ...): unused arguments (python_version = conda_python_version, pip = TRUE)Traceback:1. install_tensorflow()2. reticulate::py_install(packages = c(package, extra_packages), . envname = envname, method = method, conda = conda, python_version = conda_python_version, . pip = TRUE, ...)

Solution

  • I got the same error trying to install Keras for R. Updating to the latest reticulate version from CRAN and the latest tensorflow version from Github solved the problem:

    install.packages("reticulate")
    devtools::install_github("rstudio/tensorflow")
    

    and then

    library(tensorflow)
    install_tensorflow()
    

    I used conda instead of venvs.