Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Installation error of tensorflow and keras on Ubuntu #466

Closed
englianhu opened this issue May 15, 2021 · 4 comments
Closed

Installation error of tensorflow and keras on Ubuntu #466

englianhu opened this issue May 15, 2021 · 4 comments
Labels
awaiting response Waiting for issue author to respond installation

Comments

@englianhu
Copy link

englianhu commented May 15, 2021

Official TensorFlow for R guide on installation doesn't work, kindly look into it

✓ [main*]> devtools::install_github('rstudio/tensorflow')
Downloading GitHub repo rstudio/tensorflow@HEADchecking for file/tmp/RtmpTAAxB0/remotes1bf0d581c3af5/rstudio-tensorflow-7494495/DESCRIPTION...preparingtensorflow:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildingtensorflow_2.4.0.9000.tar.gzInstalling package into '/home/englianhu/R/x86_64-pc-linux-gnu-library/4.0'
(as 'lib' is unspecified)
* installing *source* packagetensorflow...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** help
*** installing help indices
** building package indices
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** testing if installed package can be loaded from temporary location
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** testing if installed package can be loaded from final location
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** testing if installed package keeps a record of temporary installation path
* DONE (tensorflow)
✓ [main*]> reticulate::install_miniconda()
Error: Miniconda is already installed at '/home/englianhu/.local/share/r-miniconda'
Run `rlang::last_error()` to see where the error occurred.
✓ [main*]> library(tensorflow)
ℹ tensorflow not installed. Trying to install nowInstalling tensorflow
Error: package or namespace load failed for 'tensorflow' in get(method, envir = home):
 lazy-load database '/home/englianhu/R/x86_64-pc-linux-gnu-library/4.0/tensorflow/R/tensorflow.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
2: In get(method, envir = home) :
  restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
4: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
5: In get(method, envir = home) :
  restarting interrupted promise evaluation
6: In get(method, envir = home) : internal error -3 in R_decompress1
Run `rlang::last_error()` to see where the error occurred.
✓ [main*]> devtools::session_info()$platform
 setting  value                       
 version  R version 4.0.5 (2021-03-31)
 os       Ubuntu 20.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language en                          
 collate  C                           
 ctype    en_US.UTF-8                 
 tz       Asia/Tokyo                  
 date     2021-05-15

Originally posted by @englianhu in #463 (comment)


same with keras

✓ [main*]> devtools::install_github("rstudio/keras")
Downloading GitHub repo rstudio/keras@HEADchecking for file/tmp/RtmpTAAxB0/remotes1bf0d780bcc66/rstudio-keras-67b3f18/DESCRIPTION...preparingkeras:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scripts (441ms)
─  checking for empty or unneeded directories
   Removed empty directorykeras/man-roxygen’
─  buildingkeras_2.4.0.9000.tar.gzInstalling package into '/home/englianhu/R/x86_64-pc-linux-gnu-library/4.0'
(as 'lib' is unspecified)
* installing *source* packagekeras...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** help
*** installing help indices
** building package indices
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** installing vignettes
** testing if installed package can be loaded from temporary location
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** testing if installed package can be loaded from final location
NOTE:  The Rdym package can only be used interactively.
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.3purrr   0.3.4tibble  3.1.1dplyr   1.0.6tidyr   1.1.3stringr 1.4.0readr   1.4.0forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::coalesce() masks BBmisc::coalesce()
x dplyr::collapse() masks BBmisc::collapse()
startup::startup() already installed: '~/.Rprofile'
** testing if installed package keeps a record of temporary installation path
* DONE (keras)
✓ [main*]> 
✓ [main*]> libratyi(keras)
Error in libratyi(keras) : could not find function "libratyi"
✓ [main*]> library(keras)
ℹ keras not installed. Trying to install nowInstalling keras
Error: package or namespace load failed for 'keras' in get(method, envir = home):
 lazy-load database '/home/englianhu/R/x86_64-pc-linux-gnu-library/4.0/tensorflow/R/tensorflow.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
2: In get(method, envir = home) :
  restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
4: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
5: In get(method, envir = home) :
  restarting interrupted promise evaluation
6: In get(method, envir = home) : internal error -3 in R_decompress1
Run `rlang::last_error()` to see where the error occurred.
@t-kalinowski
Copy link
Member

Hi thanks for filing.
It’s a bit difficult to follow what exactly is the issue here. It looks like you maybe have a call to library(tidyverse) and a few other things in your .Rprofile that are maybe preventing R CMD install from succeeding somehow. In particular, the line:

lazy-load database '/home/englianhu/R/x86_64-pc-linux-gnu-library/4.0/tensorflow/R/tensorflow.rdb' is corrupt)?

suggests the R package failed to install properly.

Can you reproduce this issue in a fresh R session started without .Rprofile (perhaps started with a –vanilla flag if that’s easier)

@englianhu
Copy link
Author

englianhu commented Jun 5, 2021

Download package from GitHub.

2021-06-06_03-55

> library(tensorflow)
> install_tensorflow(method = 'conda', envname = 'r-reticulate')
> use_condaenv('r-reticulate')
> library(reticulate)
> tf$constant("Hellow Tensorflow")
2021-06-06 03:27:53.040698: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /home/englianhu/anaconda3/bin/python3.8

Python exception encountered:
 NotFoundError: /home/englianhu/anaconda3/lib/python3.8/site-packages/tensorflow/core/kernels/libtfkernel_sobol_op.so: undefined symbol: _ZNK10tensorflow8OpKernel11TraceStringB5cxx11ERKNS_15OpKernelContextEb

Detailed traceback:
  File "/usr/lib/R/site-library/reticulate/python/rpytools/loader.py", line 39, in _import_hook
    module = _import(
  File "/home/englianhu/.local/lib/python3.8/site-packages/tensorflow/__init__.py", line 436, in <module>
    _ll.load_library(_main_dir)
  File "/home/englianhu/.local/lib/python3.8/site-packages/tensorflow/python/framework/load_library.py", line 153, in load_library
    py_tf.TF_LoadLibrary(lib)

You can install TensorFlow using the install_tensorflow() function.

source : Python in R - Error: could not find a Python environment for /usr/bin/python

and then move the package to library folder via terminal.

:~$ sudo apt-get install rsync -y
:~$ sudo rsync -a source/ target/

source : Rdatatable/data.table#5030 (comment)

x [master]> tf$constant("Hellow Tensorflow")
Error: Python module tensorflow was not found.

Detected Python configuration:

python:         /home/englianhu/anaconda3/bin/python3
libpython:      /home/englianhu/anaconda3/lib/libpython3.8.so
pythonhome:     /home/englianhu/anaconda3:/home/englianhu/anaconda3
version:        3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0]
numpy:          /home/englianhu/.local/lib/python3.8/site-packages/numpy
numpy_version:  1.19.5
tensorflow:     /home/englianhu/.local/lib/python3.8/site-packages/tensorflow

NOTE: Python version was forced by RETICULATE_PYTHON

x [master]> library(tensorflow)
✓ [master]> library(reticulate)
✓ [master]> tf$constant("Hellow Tensorflow")
Error: Python module tensorflow was not found.

Detected Python configuration:

python:         /home/englianhu/anaconda3/bin/python3
libpython:      /home/englianhu/anaconda3/lib/libpython3.8.so
pythonhome:     /home/englianhu/anaconda3:/home/englianhu/anaconda3
version:        3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0]
numpy:          /home/englianhu/.local/lib/python3.8/site-packages/numpy
numpy_version:  1.19.5
tensorflow:     /home/englianhu/.local/lib/python3.8/site-packages/tensorflow

NOTE: Python version was forced by RETICULATE_PYTHON

source : Rdatatable/data.table#5030 (comment)

installed through R CMD INSTALL through terminal.

:~$ wget https://cran.r-project.org/src/contrib/tensorflow_2.4.0.tar.gz
:~$ R CMD INSTALL tensorflow_2.4.0.tar.gz
...
...
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (tensorflow)
✓ [master]> library(tensorflow)
✓ [master]> library(reticulate)
✓ [master]> tf$constant("Hellow Tensorflow")
Error: Python module tensorflow was not found.

Detected Python configuration:

python:         /home/englianhu/anaconda3/bin/python3
libpython:      /home/englianhu/anaconda3/lib/libpython3.8.so
pythonhome:     /home/englianhu/anaconda3:/home/englianhu/anaconda3
version:        3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0]
numpy:          /home/englianhu/.local/lib/python3.8/site-packages/numpy
numpy_version:  1.19.5
tensorflow:     /home/englianhu/.local/lib/python3.8/site-packages/tensorflow

NOTE: Python version was forced by RETICULATE_PYTHON

@t-kalinowski
Copy link
Member

In the screen shot of the RStudio build pane, is that running within the conda environment already? If so, can you try to launch R/Rstudio from outside the conda environment, and allow reticulate to activate the conda env?

@t-kalinowski t-kalinowski added the awaiting response Waiting for issue author to respond label Jul 27, 2021
@github-actions
Copy link

Automatically closed because there has not been a response for 30 days. When you're ready to work on this further, please comment here and the issue will automatically reopen.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
awaiting response Waiting for issue author to respond installation
Projects
None yet
Development

No branches or pull requests

2 participants