I managed to install keras with
install.packages("reticulate")
install.packages("keras")
library(reticulate)
library(keras)
install_keras(method = "conda", conda = "/home/prasanna/anaconda2/envs/r-tensorflow/bin/conda", tensorflow = "gpu")
giving the output
Using r-tensorflow conda environment for TensorFlow installation
Determining latest release of TensorFlow...done
Installing TensorFlow...
Collecting tensorflow-gpu==1.3.0 from https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl
Using cached https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl
Collecting six>=1.10.0 (from tensorflow-gpu==1.3.0)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting protobuf>=3.3.0 (from tensorflow-gpu==1.3.0)
Using cached protobuf-3.4.0-cp27-cp27mu-manylinux1_x86_64.whl
Collecting wheel (from tensorflow-gpu==1.3.0)
Using cached wheel-0.29.0-py2.py3-none-any.whl
Collecting backports.weakref>=1.0rc1 (from tensorflow-gpu==1.3.0)
Using cached backports.weakref-1.0rc1-py2-none-any.whl
Collecting numpy>=1.11.0 (from tensorflow-gpu==1.3.0)
Using cached numpy-1.13.1-cp27-cp27mu-manylinux1_x86_64.whl
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow-gpu==1.3.0)
Using cached tensorflow_tensorboard-0.1.6-py2-none-any.whl
Collecting mock>=2.0.0 (from tensorflow-gpu==1.3.0)
Using cached mock-2.0.0-py2.py3-none-any.whl
Collecting setuptools (from protobuf>=3.3.0->tensorflow-gpu==1.3.0)
Using cached setuptools-36.4.0-py2.py3-none-any.whl
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Using cached Werkzeug-0.12.2-py2.py3-none-any.whl
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Using cached bleach-1.5.0-py2.py3-none-any.whl
Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow-gpu==1.3.0)
Using cached funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow-gpu==1.3.0)
Using cached pbr-3.1.1-py2.py3-none-any.whl
Installing collected packages: six, setuptools, protobuf, wheel, backports.weakref, numpy, werkzeug, html5lib, markdown, bleach, tensorflow-tensorboard, funcsigs, pbr, mock, tensorflow-gpu
Successfully installed backports.weakref-1.0rc1 bleach-1.5.0 funcsigs-1.0.2 html5lib-0.9999999 markdown-2.6.9 mock-2.0.0 numpy-1.13.1 pbr-3.1.1 protobuf-3.4.0 setuptools-36.4.0 six-1.10.0 tensorflow-gpu-1.3.0 tensorflow-tensorboard-0.1.6 werkzeug-0.12.2 wheel-0.29.0
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/prasanna/anaconda2/envs/r-tensorflow:
#
h5py 2.7.0 np113py27_0
pillow 4.2.1 py27_0
pyyaml 3.12 py27_0
requests 2.14.2 py27_0
scipy 0.19.1 np113py27_0
Installation of TensorFlow complete.
Requirement already up-to-date: keras in /home/prasanna/anaconda2/envs/r-tensorflow/lib/python2.7/site-packages
Requirement already up-to-date: pyyaml in /home/prasanna/anaconda2/envs/r-tensorflow/lib/python2.7/site-packages (from keras)
Requirement already up-to-date: numpy>=1.9.1 in /home/prasanna/anaconda2/envs/r-tensorflow/lib/python2.7/site-packages (from keras)
Requirement already up-to-date: six>=1.9.0 in /home/prasanna/anaconda2/envs/r-tensorflow/lib/python2.7/site-packages (from keras)
Requirement already up-to-date: scipy>=0.14 in /home/prasanna/anaconda2/envs/r-tensorflow/lib/python2.7/site-packages (from keras)
Installation of Keras complete.
then I followed that up with
mnist <- dataset_mnist()
which gave the error
Error in py_module_import(module, convert = convert) : ImportError: No module named keras
The same error occurs wven if I install tensorflow without the GPU option.
I looked at old issues similar to this, and could not find a fix. Help would be much appreciated !
What is the output of:
library(reticulate)
py_discover_config("keras")
You could try explicitly pointing to the r-tensorflow conda env with:
library(keras)
use_condaenv("r-tensorflow")
If that doesn't work then there may be a problem with locating CUDA / cuDNN (see the GPU installation instructions for details).
I am having the same issue the original poster described.
Here is what I see when I run py_discover_config. I see a similar output when I try use_condaenv explicitly. Any suggestions?
> library(reticulate)
> py_discover_config("keras")
python: /home/users/gmcinnes/anaconda3/bin/python
libpython: /home/users/gmcinnes/anaconda3/lib/libpython3.6m.so
pythonhome: /home/users/gmcinnes/anaconda3:/home/users/gmcinnes/anaconda3
version: 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0]
numpy: /home/users/gmcinnes/anaconda3/lib/python3.6/site-packages/numpy
numpy_version: 1.14.0
keras: [NOT FOUND]
python versions found:
/home/users/gmcinnes/anaconda3/bin/python
/usr/bin/python
/home/users/gmcinnes/anaconda3_old/bin/python
@gregmcinnes I run into same issue, did you find the solution for this? Any help will be much appreciated.
Same with me. Since this post is several month old, there should be a fix right?
Is there any solution to this problem?
Hi Everyone,
in case someone does still care...
I was able to fix the problem at least for me. In my case the problem was, that there was a path to an "old" python environment somehow hard coded in my PATH system environmental variables.
You can check on that by eighter using cmdand set PATH or from the R with e.g. strsplit(shell("set path",intern=TRUE),split=";")
After removing the old path and adding the current path to my r-tensorflow environment the system was ready to go. Probably the same should work if you don't add the new path to the system env variables but include it into the ~/.Renviron file. For me, I'm just happy that it works now, so I will not check for better solutions, but if someone does, I'm happy to improve my solution as well ;)
Most helpful comment
@gregmcinnes I run into same issue, did you find the solution for this? Any help will be much appreciated.