rstudio / tensorflow

TensorFlow for R
https://tensorflow.rstudio.com
Apache License 2.0
1.33k stars 321 forks source link

fatal error after install_tensorflow() R studio #585

Closed chaosssss123 closed 1 year ago

t-kalinowski commented 1 year ago

When opening the issue you many have noticed the "Installation Issue Template" with instructions for what information to include when opening an installation issue: https://github.com/rstudio/tensorflow/blob/main/.github/ISSUE_TEMPLATE/installation-issue.md

Can you please fill out the template?

chaosssss123 commented 1 year ago

Hi , many thanks for your help, reallya prpeciated.

I tried the code you showed me but it fails again. R studio just crashes while installing keras or/amd tensorflow and there is a message saying that R has experience a fatal error and it just crashes. then i have to re-install both R and R studio to be able to re-open R studio. Please see below details on the diagnostics:

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

reticulate::py_config() python:         C:/Users/user1/Documents/.virtualenvs/r-tensorflow/Scripts/python.exe libpython:      C:/Users/user1/AppData/Local/r-reticulate/r-reticulate/pyenv/pyenv-win/versions/3.9.13/python39.dll pythonhome:     C:/Users/user1/Documents/.virtualenvs/r-tensorflow version:        3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] Architecture:   64bit numpy:           [NOT FOUND] tensorflow:     [NOT FOUND]   NOTE: Python version was forced by import("tensorflow") > tensorflow::tf_config() Valid installation of TensorFlow not found.   Python environments searched for 'tensorflow' package:  C:\Users\user1\Documents\.virtualenvs\r-tensorflow\Scripts\python.exe   Python exception encountered:  Traceback (most recent call last):   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook     return _run_hook(name, _hook)   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 93, in _run_hook     module = hook()   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 117, in _hook     return _find_and_load(name, import_) ModuleNotFoundError: No module named 'tensorflow'     You can install TensorFlow using the install_tensorflow() function.   > reticulate::import("tensorflow") Error in py_module_import(module, convert = convert) :   ModuleNotFoundError: No module named 'tensorflow' Run `reticulate::py_last_error()` for details. > reticulate::py_last_error()   ── Python Exception Message ───────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last):   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook     return _run_hook(name, _hook)   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 93, in _run_hook     module = hook()   File "C:\Users\user1\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 117, in _hook     return _find_and_load(name, import_) ModuleNotFoundError: No module named 'tensorflow'   ── R Traceback ──────────────────────────────────────────────────────────────────────────────────────────────────────────     ▆  1. └─reticulate::import("tensorflow")  2.   └─reticulate:::py_module_import(module, convert = convert) > sessionInfo() R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)   Matrix products: default     locale: [1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   [3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           [5] LC_TIME=English_United Kingdom.utf8      time zone: Europe/London tzcode source: internal   attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base       other attached packages: [1] keras_2.13.0      reticulate_1.34.0 devtools_2.4.5    usethis_2.2.2      loaded via a namespace (and not attached):  [1] rappdirs_0.3.3         generics_0.1.3         stringi_1.7.12         lattice_0.21-8         digest_0.6.33          [6] magrittr_2.0.3         grid_4.3.1             pkgload_1.3.3          fastmap_1.1.1          rprojroot_2.0.3       [11] jsonlite_1.8.7         Matrix_1.6-1.1         processx_3.8.2         whisker_0.4.1          pkgbuild_1.4.2        [16] sessioninfo_1.2.2      urlchecker_1.0.1       ps_1.7.5               tfruns_1.5.1           promises_1.2.1        [21] tensorflow_2.14.0.9000 purrr_1.0.2            cli_3.6.1              shiny_1.7.5            rlang_1.1.1           [26] crayon_1.5.2           pak_0.6.0              ellipsis_0.3.2         withr_2.5.1            remotes_2.4.2.1       [31] base64enc_0.1-3        cachem_1.0.8           tools_4.3.1            memoise_2.0.1          zeallot_0.1.0         [36] httpuv_1.6.11          here_1.0.1             curl_5.1.0             vctrs_0.6.4            R6_2.5.1              [41] mime_0.12              png_0.1-8              lifecycle_1.0.3        stringr_1.5.0          fs_1.6.3              [46] htmlwidgets_1.6.2      miniUI_0.1.1.1         desc_1.4.2             callr_3.7.3            later_1.3.1            [51] glue_1.6.2             profvis_0.3.8          Rcpp_1.0.11            rstudioapi_0.15.0      xtable_1.8-4          [56] htmltools_0.5.6.1      compiler_4.3.1         prettyunits_1.2.0 --   > | > >

 

t-kalinowski commented 1 year ago

Can you please paste the output by copy pasting directly from Rstudio Console or Terminal? It looks like you copypasted into microsoft word, and then somehow pasted in the raw XML from a ms word document into the github issue.

t-kalinowski commented 1 year ago

Can you please include the output from running all the the other installation commands in the issue template?

t-kalinowski commented 1 year ago

Is there any other output with the "fatal error". Does the entire RStudio session crash?

If the RStudio session crashes, can you please run the commands outside of RStudio, and report back with the full output you see? E.g., in cmd.exe. If R is not on your PATH, In RStudio you can call R.home("bin/R") to get the path to R.exe, and then paste that into cmd.exe to start R.

chaosssss123 commented 1 year ago

Downloading charset_normalizer-3.3.0-cp39-cp39-win_amd64.whl (98 kB) ---------------------------------------- 98.2/98.2 kB 5.5 MB/s eta 0:00:00 Downloading importlib_metadata-6.8.0-py3-none-any.whl (22 kB) Downloading MarkupSafe-2.1.3-cp39-cp39-win_amd64.whl (17 kB) Downloading urllib3-2.0.6-py3-none-any.whl (123 kB) ---------------------------------------- 123.8/123.8 kB 7.1 MB/s eta 0:00:00 Downloading zipp-3.17.0-py3-none-any.whl (7.4 kB) ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\Users\User1\AppData\Local\Temp\pip-unpack-bi8sc5t8\tensorflow-2.14.0-cp39-cp39-win_amd64.whl'

WARNING: There was an error checking the latest version of pip.

t-kalinowski commented 1 year ago

If you run a pip install command in cmd.exe, do you get the same error?

"C:/Users/User1/Documents/.virtualenvs/r-tensorflow/Scripts/python.exe" -m pip install --upgrade --no-user tensorflow
t-kalinowski commented 1 year ago

Are you running in the Windows application named "cmd.exe", or in Rstudio console?

chaosssss123 commented 1 year ago

I rerun in cmd, it does install TensorFlow without crashing but then cmd gets back to C:\Users\User1, so typing again C:/PROGRA~1/R/R-43~1.1/bin/R gets an error. I then realised that this happens because after installing tensorflow R crashed again even if i installed it within cmd. So, again we are back to the same, vicious cycle. cmd does nto solve the problem. something is preventing r studio /r from isntalling keras/tensorflow.

t-kalinowski commented 1 year ago

If you're encountering an error when running the system command python -m pip install tensorflow in cmd.exe, then I don't think there is anything the R package can do to fix that.

It could be any number of issues:

It is difficult to diagnose without more information, and also, I believe the error you're experiencing is extremely uncommon. The R function install_tensorflow() works without any issues for the vast majority of people.

My advice is to find a local expert who can help you navigate this unique situation. Additionally, if you get tensorflow working in a Python installation on your machine, you can always point R at it by setting the env var RETICULATE_PYTHON.

Also, please stop spamming across the different repos with the same issue.