Keras: R Session Aborted when executing any Keras function

Created on 8 Mar 2018  Â·  6Comments  Â·  Source: rstudio/keras

Hi,

I have R version 3.4.3 on Mac OS 10.11.6 (El Capitan) installed. I installed Keras by executing:

install.packages("keras")
install_keras()

However, I was prompted the following error message:

Error: Prerequisites for installing TensorFlow not available.

Execute the following at a terminal to install the prerequisites:

$ sudo /usr/bin/easy_install pip
$ sudo /usr/local/bin/pip install --upgrade virtualenv

Hence, I executed both lines in the Mac Terminal. While doing so a warning message popped up stating:

The directory '/Users/xxx/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag

Nevertheless, both commands seemed to run through successful. Afterwards I executed install_keras() again and everything seemed to install correctly.

A new R session was started and after loading the Keras library and executing:
imdb = dataset_imdb(num_words = 10000)
I got a warning message, which said:

FutureWarning: Conversion of the second argument of issubdtype from ‘float’ to ‘np.floating’ is depreciated…

Furthermore, the R session encountered a fatal error and R restarted.

R session Aborted, R encountered a fatal error. The session was terminated.

From here on I tried a lot of different things to fix the problem, but nothing helped. I installed Anaconda and tried install_keras(method="conda") after removing and reinstalling the keras package. I also tried uninstalling python completely, reinstalled R but nothing changed.

Interestingly on an other Mac machine where I run R 3.4.2 on Mac OS 10.12.6 (Sierra) I got Keras to work. However, I installed Anaconda3 right away and chose install_keras(method="conda") right away after installing the package. Hence, I did not get the error message

Error: Prerequisites for installing TensorFlow not available.

Execute the following at a terminal to install the prerequisites:

$ sudo /usr/bin/easy_install pip
$ sudo /usr/local/bin/pip install --upgrade virtualenv
in the first place.

Besides, a complete reinstall of Mac OS X, which is not really a convenient option I don't know what to do about this. Do you have any ideas about this issue?

I would much appreciate the help since I need to use this package for my master thesis.

*Edit: After even more Googling this guy on Stackoverflow seems to have the same issue as I. However, noone has responded yet...
https://stackoverflow.com/questions/49101859/when-trying-to-run-any-keras-code-r-session-aborts

*Edit 2: The following two lines also crash R:

library(tensorflow)
tf_config()

Most helpful comment

Newer version of TF require newer processors. The error you are seeing
typically occurs when running TF on an older machine. Try installing an
older version of TF e.g. with install_tensorflow(version = "1.4")

On Thu, Jun 14, 2018 at 9:19 AM gyl89 notifications@github.com wrote:

I got the same issue. At first, I though it was because of the
installation containing some warnings (the install_tensorflow function
looks for executable of python in usr/bin while this folder only contained
an old version of python for me. I had to redefine a new function
install_tensorflow where I force the python folder to be different). Now
that the installation is perfectly fine, R still crashes after I try any
tensorflow command. Here is the traceback:
``* caught illegal operation *
address 0x114e2bacb, cause 'illegal opcode'

Traceback:
1: .Call(_reticulate_py_module_import, module, convert)
2: py_module_import(module, convert = convert)
3: import(module)
4: doTryCatch(return(expr), name, parentenv, handler)
5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(import(module), error = clear_error_handler())
8: py_resolve_module_proxy(x)
9: $.python.builtin.module(tf, Session)
10: tf$Session

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rstudio/keras/issues/313#issuecomment-397292613, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGXx0_Mh9nhGgdKIO8TP6mbG7Iu4kyzks5t8mJmgaJpZM4SjAev
.

All 6 comments

I am having similar issues but believe it's not a Keras or Tensorflow issue but a reticulate issue because my R sessions are similarly aborted even if I just call reticulate::import("os").

I suggest closing this issue and opening one at https://github.com/rstudio/reticulate

I have the same issue, i.e. everytime keras encounters a mistake, and oftentimes when it does not, it crashes Rstudio with "fatal error". However, it's not a reticulate issue, as @ellisvalentiner 's code works fine; also the last piece of code of OP also works fine. Pls help, that is annoying as fuck.

I have a similar issue, any Keras function causes R to crash with fatal error. reticulate::import("os") works fine.

I got the same issue. At first, I though it was because of the installation containing some warnings (the install_tensorflow function looks for executable of python in usr/bin while this folder only contained an old version of python for me. I had to redefine a new function install_tensorflow where I force the python folder to be different). Even after the installation got perfectly fine, R still crashed for any tensorflow command.

I got the traceback:
``* caught illegal operation *
address 0x114e2bacb, cause 'illegal opcode'

Traceback:
1: .Call(_reticulate_py_module_import, module, convert)
2: py_module_import(module, convert = convert)
3: import(module)
4: doTryCatch(return(expr), name, parentenv, handler)
5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(import(module), error = clear_error_handler())
8: py_resolve_module_proxy(x)
9: $.python.builtin.module(tf, Session)
10: tf$Session

After intensively searching on google similar issues, I have found:
https://github.com/rstudio/tensorflow/issues/228

Installing an older version of tensorflow worked for me

Newer version of TF require newer processors. The error you are seeing
typically occurs when running TF on an older machine. Try installing an
older version of TF e.g. with install_tensorflow(version = "1.4")

On Thu, Jun 14, 2018 at 9:19 AM gyl89 notifications@github.com wrote:

I got the same issue. At first, I though it was because of the
installation containing some warnings (the install_tensorflow function
looks for executable of python in usr/bin while this folder only contained
an old version of python for me. I had to redefine a new function
install_tensorflow where I force the python folder to be different). Now
that the installation is perfectly fine, R still crashes after I try any
tensorflow command. Here is the traceback:
``* caught illegal operation *
address 0x114e2bacb, cause 'illegal opcode'

Traceback:
1: .Call(_reticulate_py_module_import, module, convert)
2: py_module_import(module, convert = convert)
3: import(module)
4: doTryCatch(return(expr), name, parentenv, handler)
5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(import(module), error = clear_error_handler())
8: py_resolve_module_proxy(x)
9: $.python.builtin.module(tf, Session)
10: tf$Session

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rstudio/keras/issues/313#issuecomment-397292613, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGXx0_Mh9nhGgdKIO8TP6mbG7Iu4kyzks5t8mJmgaJpZM4SjAev
.

@jjallaire Downgrading TF worked, thanks - I am running on an old machine. Some things need Keras to be downgraded as well, I think the best solution is a hardware upgrade!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gundalav picture gundalav  Â·  3Comments

tbonne picture tbonne  Â·  5Comments

leonjessen picture leonjessen  Â·  4Comments

saanasum picture saanasum  Â·  4Comments

fderyckel picture fderyckel  Â·  4Comments