R not recognizing my tensorflow install

Hi all

I'm having trouble making R find my tensorflow installation. When I run the following:

library("tensorflow")

use_condaenv(condaenv = "tf_gpu", conda = "/home/cbrunos/miniconda3/bin/conda")

hello <- tf$constant('Hello, TensorFlow!')

I get this error:

> hello <- tf$constant('Hello, TensorFlow!')
Error: Python module tensorflow was not found.

Detected Python configuration:

python:         /home/cbrunos/miniconda3/envs/tf_gpu/bin/python
libpython:      /home/cbrunos/miniconda3/envs/tf_gpu/lib/libpython3.6m.so
pythonhome:     /home/cbrunos/miniconda3/envs/tf_gpu:/home/cbrunos/miniconda3/envs/tf_gpu
version:        3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)  [GCC 7.3.0]
numpy:          /home/cbrunos/miniconda3/envs/tf_gpu/lib/python3.6/site-packages/numpy
numpy_version:  1.15.4
tensorflow:     /home/cbrunos/miniconda3/envs/tf_gpu/lib/python3.6/site-packages/tensorflow

python versions found: 
 /home/cbrunos/miniconda3/envs/tf_gpu/bin/python
 /usr/bin/python
 /usr/bin/python3
 /home/cbrunos/miniconda3/bin/python

However, it works from Python:

import tensorflow as tf
if tf.test.gpu_device_name():
    print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
    print("Please install GPU version of TF")

## -- End pasted text --
2019-02-17 01:22:16.949833: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2019-02-17 01:22:16.949882: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-02-17 01:22:16.949893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 
2019-02-17 01:22:16.949903: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N 
2019-02-17 01:22:16.950045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/device:GPU:0 with 7460 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:22:00.0, compute capability: 6.1)
2019-02-17 01:22:16.950667: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2019-02-17 01:22:16.950692: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-02-17 01:22:16.950702: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 
2019-02-17 01:22:16.950710: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N 
2019-02-17 01:22:16.950818: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/device:GPU:0 with 7460 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:22:00.0, compute capability: 6.1)
Default GPU Device: /device:GPU:0

Below some more info. Everything seems to be fine, but R does not find tensorflow. I would like to use the same miniconda environment I'm using from Python in R. Any ideas?

> reticulate::conda_list()
        name                                          python
1 miniconda3             /home/cbrunos/miniconda3/bin/python
2     tf_gpu /home/cbrunos/miniconda3/envs/tf_gpu/bin/python
> reticulate::py_config()
python:         /home/cbrunos/miniconda3/envs/tf_gpu/bin/python
libpython:      /home/cbrunos/miniconda3/envs/tf_gpu/lib/libpython3.6m.so
pythonhome:     /home/cbrunos/miniconda3/envs/tf_gpu:/home/cbrunos/miniconda3/envs/tf_gpu
version:        3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)  [GCC 7.3.0]
numpy:          /home/cbrunos/miniconda3/envs/tf_gpu/lib/python3.6/site-packages/numpy
numpy_version:  1.15.4
tensorflow:     /home/cbrunos/miniconda3/envs/tf_gpu/lib/python3.6/site-packages/tensorflow

python versions found: 
 /home/cbrunos/miniconda3/envs/tf_gpu/bin/python
 /usr/bin/python
 /usr/bin/python3
 /home/cbrunos/miniconda3/bin/python
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /home/cbrunos/miniconda3/envs/tf_gpu/lib/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_LU.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=de_LU.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=de_LU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_LU.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] tensorflow_1.8       RevoUtils_11.0.1     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] compiler_3.5.1  magrittr_1.5    Matrix_1.2-14   tools_3.5.1     whisker_0.3-2   base64enc_0.1-3
 [7] Rcpp_0.12.18    reticulate_1.9  grid_3.5.1      jsonlite_1.5    tfruns_1.3      lattice_0.20-35

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.