Andreas
Andreas

Reputation: 737

R, TensorFlow, Anaconda Install on Windows

I'm tryiing to install tensorflow for R. For this purpose I installed the latest version of Anaconda (4.3.1) to my OS and installed everything as described in:

https://rstudio.github.io/tensorflow/installation.html

To get started, install the tensorflow R package from GitHub as follows:

devtools::install_github("rstudio/tensorflow")

Then, use the install_tensorflow() function to install TensorFlow:

library(tensorflow)
install_tensorflow()

The result of this process is a folder ~\AppData\Local\conda\conda\envs\r-tensorflow which should be used by Anaconda as an Evironment. This environment is not recognized by the current version of Anaconda.

But the output in R is:

Error: Python module tensorflow was not found.

Detected Python configuration:

python:         C:\PROGRA~3\ANACON~1\python.exe
libpython:      C:/PROGRA~3/ANACON~1/python36.dll
pythonhome:     C:\PROGRA~3\ANACON~1
version:        3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016,  11:57:41) [MSC v.1900 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:\PROGRA~3\ANACON~1\lib\site-packages\numpy
numpy_version:  1.11.3
tensorflow:     [NOT FOUND]

No comes my guessing:

  1. Anaconda 4.3.1 does use the folder C:\ProgramData\Anaconda3\pkgs for its packages and does not use the folder above at all. This might be the cause why tensorflow is not found.

  2. The described process from https://rstudio.github.io/tensorflow/installation.html does not match the latest version of anaconda.

Can you show me how to get tensorflow to work with the latest versions of R, tensorflow and Anaconda?

I tried to install r-tensorflow to the global Anaconda environment via

conda install -c conda-forge r-tensorflow

It is not recognized by the environment loaded in R. Can I change the environment of tensorflow directly in R?

Upvotes: 1

Views: 4394

Answers (2)

Nandha Kumar M
Nandha Kumar M

Reputation: 65

My suggestion is to install using the Anaconda Navigator step 1: Open Anaconda Navigator and change the Application on from "Root to Tensorflow" channel (top left) Step 2: Now install the R available below

Upvotes: 0

Andreas
Andreas

Reputation: 737

Ok, I found out that in the case of tensorflow and Anaconda used I need to force Anaconda to use the Tensorflow environment before i can use it. This is not included in the R tensorflow library so far and must be set by the reticulate library:

#set anaconda to tensor flow environment
library(reticulate)
use_condaenv("r-tensorflow")
#Alternative
use_condaenv(condaenv = "r-tensorflow", conda = "YOUR_ANACONDA_PATH")

I posted an issue here:

https://github.com/rstudio/tensorflow/issues/119

Upvotes: 4

Related Questions