reticulate 1.14 together with Miniconda3 and tensorflow not working


I was very excited to read Kevin Ushey's 2019-12-20 blog contribution on reticulate 1.4, since it promised to make using Python power, e.g. from tensorflow and keras, available to R and in particular to RStudio.

I'm using WIN10-64 together with R3.6.2, RStudio 1.2.5033 and RTools 3.5, and was expecting a smooth transfer from my rather ancient installation with Anaconda3 and earlier versions of reticulate, tensorflow and keras.

However, much to my disappointment, it doesn't work at all like described:

  1. reticulate 1.4 was installed and attached; the command "library(tensorflow)" simply produced the message "object tensorflow not found"

  2. tensorflow 2.0.0 installed and attached separately: no reaction

  3. keras installed and attached: reticulate starts installation of miniconda; after 2hrs of 75...100% CPU load I had to terminate R via WIN-Task-Mgr., no other option to influence the process

  4. using reticulate::install_miniconda() starts the installation process successfully, WIN indicates Miniconda3 v4.7.12 (Python 3.7.4) to be installed correctly

  5. attaching reticulate again - object tensorflow not found, same with keras

  6. is_keras_available => FALSE (as expected at this stage, I must confess)

Since I have removed my (very ancient but working) keras-installation (together with previous reticulate, tensorflow, Anaconda3 as well as Python 3.7), I am at this moment unable to continue my work based on keras. Any suggestion what I could do would be highly appreciated...

Tnx in advance

Leo Faltin

Tnx andresrcs for allocating my post to more suitable topics!

Perhaps I shoul add some additional information regarding the present state of my reticulate/tensorflow/keras installation. My RStudio console shows the following:

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] keras_2.2.5.0 tensorflow_2.0.0 reticulate_1.14

loaded via a namespace (and not attached):
[1] compiler_3.6.2 R6_2.4.1 magrittr_1.5 generics_0.0.2
[5] tools_3.6.2 whisker_0.4 base64enc_0.1-3 rappdirs_0.3.1
[9] Rcpp_1.0.3 zeallot_0.1.0 jsonlite_1.6 tfruns_1.4

python: C:/.../Local/r-miniconda/envs/r-reticulate/python.exe
libpython: C:/.../Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome: C:/.../Local/r-miniconda/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, Jan 7 2020, 15:18:16) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/.../Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.17.4

What puzzles me: Although all 3 necessary packages (reticulate, tensorflow & keras) are attached, keras is not available. Moreover, the file structure embedding miniconda looks rather baroque and I simply doubt whether this is normal and/or necessary.

Moreover, there seems to be a conflict regarding the python version installed: according to what WIN10 communicates, I have Miniconda3 v4.7.12 (Python 3.7.4), wheras the command py_config shows v3.6.10. Don't know what this tells me...

After several hours of trial and error to reticulate Python to Tensorflow there are first silver linings at the horizon: Using the commands

use_condaenv("r-tensorflow", required = TRUE)

gives (for the first application after several mins waiting time, after that about 15secs after every new start of the R program sheet) the long hoped for message

[1] TRUE

and permitting insight into what these commands have done in the meantime:

python:         C:/.../Local/conda/conda/envs/r-tensorflow/python.exe
libpython:      C:/.../Local/conda/conda/envs/r-tensorflow/python36.dll
pythonhome:     C:/.../Local/conda/conda/envs/r-tensorflow
version:        3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/.../Local/conda/conda/envs/r-tensorflow/Lib/site-packages/numpy
numpy_version:  1.14.3
tensorflow:     C:\...\Local\conda\conda\envs\R-TENS~1\lib\site-packages\tensorflow\__init__.p
NOTE: Python version was forced by use_python function

Compared with the first part of my posts this shows that there has been some transmogrification from Miniconda3 v4.7.12 (Python 3.7.4), which my WIN10 is still indicating, over (Python) version: 3.6.10 as in my 2nd post, to finally (Python) version: 3.6.6 as regards Python in this final state. Numpy has been downgraded as well, btw. And Tensorflow has suffered, too:

TensorFlow v1.5.0 (C:\...\Local\conda\conda\envs\R-TENS~1\lib\site-packages\tensorflow\__init__.p)
Python v3.6 (C:/.../Local/conda/conda/envs/r-tensorflow/python.exe)

(sessionInfo() still shows tensorflow_2.0.0). Nevertheless, Keras seems to be available.

All this is far away from the promised land of fully automated availability of Python to Tensorflow and hopefully Keras by reticulate v1.14, but nevertheless: a 1st success.

Finally, a bad surprise with this setup: there are serious downward compatibility problems with keras, completely inhibiting use of previously working programmes.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.