RStudio --> Error: Python module tensorflow.keras was not found - r

But I am working in RStudio. and facing the below error related with Keras & Tensorflow.
Error: Python module tensorflow.keras was not found.
Detected Python configuration:
python: C:/Users/AppData/Local/r-miniconda/envs/r-reticulate/python.exe
libpython: C:/Users/AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome: C:/Users/AppData/Local/r-miniconda/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.18.5
Any help on this is very appreciable.

Related

Installation of TensorFlow not found in Rstudio (on Mac)

I am new to TensorFlow and Keras and I installed them in Rstudio using a conda virtual environment. I run the following line and everything works.
library(reticulate)
use_condaenv("r-reticulate")
library(tensorflow)
library(keras)
However when I try to call the function "keras_model_sequential()" I get this error:
**Error: Python module tensorflow.keras was not found.
Detected Python configuration:
python: /anaconda3/envs/r-reticulate/bin/python
libpython: //anaconda3/envs/r-reticulate/lib/libpython3.6m.dylib
pythonhome: /anaconda3/envs/r-reticulate:/anaconda3/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: /anaconda3/envs/r-reticulate/lib/python3.6/site-packages/numpy
numpy_version: 1.19.2
tensorflow: /anaconda3/envs/r-reticulate/lib/python3.6/site-packages/tensorflow
python versions found:
/anaconda3/envs/r-reticulate/bin/python
/usr/bin/python
/anaconda3/envs/covid19/bin/python
/anaconda3/envs/test/bin/python
/anaconda3/envs/test2/bin/python
**
What should I do? I am using a Mac with El Capitan (version 10.11.6). Thank you very much Riccardo

Saltstack module is not available

Trying to run sls but the salt tells me the function is not available
My sls. Must create a mongodump file
create-dump:
module.run:
- name: docker.run
- m_name: mongo
- cmd: 'mongodump --out=/Mongodump
when i'm run salt minion state.sls sls
i see:
ID: create-dump
Function: module.run
Name: docker.run
Result: False
Comment: Module function docker.run is not available
Started: 06:03:40.273781
Duration: 728.234 ms
Changes:
--Versions
Salt Version:
Salt: 3000
Dependency Versions:
cffi: 1.9.1
cherrypy: 3.5.0
dateutil: 2.5.3
docker-py: 4.3.1
gitdb: 2.0.0
gitpython: 2.1.1
Jinja2: 2.8
libgit2: 0.24.5
M2Crypto: Not Installed
Mako: 1.0.6
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: 1.3.7
pycparser: 2.17
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.24.2
Python: 3.5.3 (default, Jul 9 2020, 13:00:10)
python-gnupg: 0.3.9
PyYAML: 3.12
PyZMQ: 16.0.2
smmap: 2.0.1
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.2.1
System Versions:
dist: debian 9.6
locale: UTF-8
machine: x86_64
release: 4.9.0-8-amd64
system: Linux
version: debian 9.6
tried pip3 uninstall docker - not work
If i'm reboot server docker-py downgrade to 1.10.6 version
Make sure python-docker is installed on the minion.

CuDNN is not available in binary-installed cupy

I installed Cupy using the binary package cupy-cuda92, but CuDNN is not loaded.
$ pip install cupy-cuda92==5.4.0 chainer==5.4.0
$ python -c 'import chainer; chainer.print_runtime_info()'
/home/xxxxx/.pyenv/versions/3.5.2/lib/python3.5/site-packages/chainer/backends/cuda.py:98: UserWarning: cuDNN is not enabled.
Please reinstall CuPy after you install cudnn
(see https://docs-cupy.chainer.org/en/stable/install.html#install-cudnn).
'cuDNN is not enabled.\n'
Platform: Linux-4.4.0-103-generic-x86_64-with-debian-stretch-sid
Chainer: 5.3.0
NumPy: 1.16.2
CuPy:
CuPy Version : 5.3.0
CUDA Root : /usr/local/cuda
CUDA Build Version : 9020
CUDA Driver Version : 9020
CUDA Runtime Version : 9020
cuDNN Build Version : None
cuDNN Version : None
NCCL Build Version : 2307
NCCL Runtime Version : 2402
iDeep: Not Available
I tried uninstalling & reinstalling chainer and cupy with --no-cache-dir but saw no difference. I also confirmed that CUDA is 9.2.
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Wed_Apr_11_23:16:29_CDT_2018
Cuda compilation tools, release 9.2, V9.2.88
I found the problem and a solution on my own.
First I tried to import cudnn directly.
$ python
Python 3.5.2 (default, Mar 25 2019, 10:54:56)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupy.cuda.cudnn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/xxxxx/.pyenv/versions/3.5.2/lib/python3.5/site-packages/cupy/cuda/cudnn.cpython-35m-x86_64-linux-gnu.so: symbol cudnnGetBatchNormalizationTrainingExReserveSpaceSize, version libcudnn.so.7 not defined in file libcudnn.so.7 with link time reference
thus there is a kind of library version mismatch. I checked my LD_LIBRARY_PATH and found that different versions of CuDNN are installed via cudnnenv. I removed them from LD_LIBRARY_PATH and the problem was gone.
$ python -c 'import chainer; chainer.print_runtime_info()'
Platform: Linux-4.4.0-103-generic-x86_64-with-debian-stretch-sid
Chainer: 5.3.0
NumPy: 1.16.2
CuPy:
CuPy Version : 5.3.0
CUDA Root : /usr/local/cuda
CUDA Build Version : 9020
CUDA Driver Version : 9020
CUDA Runtime Version : 9020
cuDNN Build Version : 7402
cuDNN Version : 7500
NCCL Build Version : 2307
NCCL Runtime Version : 2402
iDeep: Not Available

Error: ModuleNotFoundError: No module named 'keras' when using keras in R

I have a problem running Keras in R. When running mnist <- dataset_mnist() I get the error Error: ModuleNotFoundError: No module named 'keras'
I have installed the most recent version of Anaconda, I am running R version 3.5.1 in RStudio 1.1.463. In R I have run
library("keras")
install_keras()
and this succeeds.
When trying to run mnist <- dataset_mnist() I initially got the following error message:
ImportError: No module named keras
Use the install_keras() function to install the core Keras library
Error: Error loading Python module keras
When running
library(reticulate)
py_config()
I got the following output:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
keras: [NOT FOUND]
After looking at suggested solutions to other topics, I added this line to my .Rprofile
Sys.setenv(RETICULATE_PYTHON = "/anaconda3/envs/r-tensorflow/bin")
However when I run mnist <- dataset_mnist() now I get the following error:
Error: Python module keras was not found.
Detected Python configuration:
python: /anaconda3/envs/r-tensorflow/bin/python
libpython: /anaconda3/envs/r-tensorflow/lib/libpython3.6m.dylib
pythonhome: /anaconda3/envs/r-tensorflow:/anaconda3/envs/r-tensorflow
version: 3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:37:09) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: [NOT FOUND]
keras: /anaconda3/envs/r-tensorflow/lib/python3.6/site-packages/keras
NOTE:
Does anyone know what I can do to solve this?

How to set pyenv python for reticulate

I'm using 1.10 version of reticulate package ( R version is 3.5.1) and I want to configure it to use pyenv python (path is /Users/name/.pyenv/versions/hak/bin/python). Running py_config() won't show me this python as available:
python: /usr/bin/python
libpython:
/System/Library/Frameworks/Python.
framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:
/System/Library/Frameworks/Python.
framework/Versions/2.7:/System/Library
/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/ Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
python versions found:
/usr/bin/python
/usr/local/bin/python
/usr/local/bin/python3
Because my pyenv python isnt available I set RETICULATE_PYTHON env variable on mentioned path. But now i get the error
Error in initialize_python(required_module, use_environment) :
Python shared library
'/Users/name/.pyenv/versions/3.6.5/lib/libpython3.6.dylib'
not found, Python bindings not loaded.
Does anybody know how to solve this ?
pyenv doesn't build pythons with shareable libraries by default. to make sure it does either have the CONFIGURE_OPTIONS variable set or preface your pyenv build $VERSION commands as in the example below:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5
see:
https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md#building-with---enable-shared)

Resources