I tried to run keras package from R in RStudio as shown in this tutorial . However, I get stuck by loading data from mnist dataset with the command mnist <- dataset_mnist()
as I get the error:
Error: Python module tensorflow.python.keras was not found.
Detected Python configuration:
python: C:\PROGRA~3\ANACON~1\python.exe
libpython: C:/PROGRA~3/ANACON~1/python37.dll
pythonhome: C:\PROGRA~3\ANACON~1
version: 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\PROGRA~3\ANACON~1\lib\site-packages\numpy
numpy_version: 1.16.2
tensorflow: [NOT FOUND]
python versions found:
C:\PROGRA~3\ANACON~1\python.exe
C:\ProgramData\Anaconda3\python.exe
It seems not to find tensorflow package, which is already installed as installed.packages()
shows:
Package LibPath Version Priority
keras "keras" "C:/Users/NikolasVarela/Documents/R/win-library/3.5" "2.2.4.1.9001" NA
tensorflow "tensorflow" "C:/Users/NikolasVarela/Documents/R/win-library/3.5" "1.13.1" NA
I previously manually installed Anaconda for python 3.7 and downgraded in the Anaconda Navigator to 3.6 as shown in this udemy tutorial as mentioned that tensorflow only runs on python 3.6. After that I downloaded all needed packages including tensorflow and keras on the anaconda navigator. I assume that this manuell change makes the problem in finding tensorflow. But I didn't find a solution on the web.
Further, I tried to set the path of the dataset_mnist()
function as mentioned in the description . However, I don't find a ~/.keras/datasets
on my directory. Any ideas what I'm doing wrong? Thanks
I had the same problem. I finally resolved it as follows:
conda create -y --name r-tensorflow tensorflow-gpu keras-gpu python=3.6.8
. (Note: I'm not sure it is necessary to install the keras-gpu package here.) keras::use_condaenv("r-tensorflow", required = TRUE)
. Now it should work. Try the following if you don't mind downloading the MNIST database:
library(keras) mnist <- dataset_mnist()
PS. I've first tried installing via R as follows:
install.packages("keras")
library(keras)
install_keras(method = c("conda"),
conda = "auto", version = "default", tensorflow = "gpu")
PPS. Of course you need to already have Python, Anaconda/Miniconda, CUDA and cuDNN installed as well as some other requirements. I'm assuming you have and that you don't have version conflicts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.