r - 如何使用 Linux Debian 正确安装 R keras

标签 r tensorflow ubuntu keras

我有虚拟 Debian 服务器。即

braingen@vm-mob:~$ Linux vm-mob 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64

我已经安装了 r-base-core

sudo apt-get install r-base-core
R

当在 R 控制台中时,我尝试安装 keras

install.packages("keras")

当我这样做时,我遇到了麻烦

he downloaded source packages are in
        ‘/tmp/RtmpxmyvE9/downloaded_packages’
Warning messages:
1: In install.packages("keras") :
  installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("keras") :
  installation of package ‘png’ had non-zero exit status
3: In install.packages("keras") :
  installation of package ‘reticulate’ had non-zero exit status
4: In install.packages("keras") :
  installation of package ‘tfautograph’ had non-zero exit status
5: In install.packages("keras") :
  installation of package ‘tfruns’ had non-zero exit status
6: In install.packages("keras") :
  installation of package ‘tensorflow’ had non-zero exit status
7: In install.packages("keras") :
  installation of package ‘keras’ had non-zero exit status
>

所以我当然无法加载库。

如何正确安装 keras 和依赖项? 谢谢

完整日志

> install.packages("keras")
Installing package into ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘Rcpp’, ‘png’, ‘tfautograph’, ‘reticulate’, ‘tensorflow’, ‘tfruns’

trying URL 'https://cloud.r-project.org/src/contrib/Rcpp_1.0.7.tar.gz'
Content type 'application/x-gzip' length 2941808 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/png_0.1-7.tar.gz'
Content type 'application/x-gzip' length 24990 bytes (24 KB)
==================================================
downloaded 24 KB

trying URL 'https://cloud.r-project.org/src/contrib/tfautograph_0.3.1.tar.gz'
Content type 'application/x-gzip' length 46883 bytes (45 KB)
==================================================
downloaded 45 KB

trying URL 'https://cloud.r-project.org/src/contrib/reticulate_1.20.tar.gz'
Content type 'application/x-gzip' length 832951 bytes (813 KB)
==================================================
downloaded 813 KB

trying URL 'https://cloud.r-project.org/src/contrib/tensorflow_2.6.0.tar.gz'
Content type 'application/x-gzip' length 46786 bytes (45 KB)
==================================================
downloaded 45 KB

trying URL 'https://cloud.r-project.org/src/contrib/tfruns_1.5.0.tar.gz'
Content type 'application/x-gzip' length 2011046 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

trying URL 'https://cloud.r-project.org/src/contrib/keras_2.6.0.tar.gz'
Content type 'application/x-gzip' length 3462992 bytes (3.3 MB)
==================================================
downloaded 3.3 MB

* installing *source* package ‘Rcpp’ ...
 package ‘Rcpp’ successfully unpacked and MD5 sums checked
 libs
g++  -I"/usr/share/R/include" -DNDEBUG -I../inst/include/     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c api.cpp -o api.o
/bin/bash: g++: command not found
make: *** [/usr/lib/R/etc/Makeconf:171: api.o] Error 127
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/Rcpp’
* installing *source* package ‘png’ ...
 package ‘png’ successfully unpacked and MD5 sums checked
 libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG      libpng-config --cflags -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c read.c -o read.o
/bin/bash: libpng-config: command not found
read.c:3:10: fatal error: png.h: No such file or directory
 #include <png.h>
          ^~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:162: read.o] Error 1
ERROR: compilation failed for package ‘png’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/png’
ERROR: dependencies ‘Rcpp’, ‘png’ are not available for package ‘reticulate’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/reticulate’
ERROR: dependency ‘reticulate’ is not available for package ‘tfautograph’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/tfautograph’
ERROR: dependency ‘reticulate’ is not available for package ‘tfruns’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/tfruns’
ERROR: dependencies ‘reticulate’, ‘tfruns’, ‘tfautograph’ are not available for package ‘tensorflow’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/tensorflow’
ERROR: dependencies ‘reticulate’, ‘tensorflow’, ‘tfruns’ are not available for package ‘keras’
* removing ‘/home/braingen/R/x86_64-pc-linux-gnu-library/3.5/keras’

Brain gen, [25.08.21 13:53]
The downloaded source packages are in
        ‘/tmp/RtmpxmyvE9/downloaded_packages’
Warning messages:
1: In install.packages("keras") :
  installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("keras") :
  installation of package ‘png’ had non-zero exit status
3: In install.packages("keras") :
  installation of package ‘reticulate’ had non-zero exit status
4: In install.packages("keras") :
  installation of package ‘tfautograph’ had non-zero exit status
5: In install.packages("keras") :
  installation of package ‘tfruns’ had non-zero exit status
6: In install.packages("keras") :
  installation of package ‘tensorflow’ had non-zero exit status
7: In install.packages("keras") :
  installation of package ‘keras’ had non-zero exit status
>

最佳答案

由于缺少系统 header ,“png”包似乎无法安装。我在 Docker 容器中尝试过,但无法在本地重现您的错误。两个想法: a) 也许需要一些额外的系统依赖项,但您正在使用的 debian 镜像中未包含这些依赖项?也许像 apt install png-dev 这样的东西可以让它工作。

b) 也许更新 R 版本? R 3.5 已发布 3 年多了,这可能是问题的根本原因,R 当前的发布版本是 4.1.1。

关于r - 如何使用 Linux Debian 正确安装 R keras,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68921617/

相关文章:

R:将参数传递给外部()

python - Keras CNN LSTM(TF 后端)的显着图

ubuntu - Alt+Tab 后 Android 模拟器窗口保持在顶部

qt - 无法将不兼容的 Qt 库(版本 0x50501)与此库(版本 0x50201)混合使用

r - 如何在散点图矩阵中留下不显着值的空白单元格?

r - 组合两个不同长度的数据帧

r - 具有标准误差的个体随机效应模型聚集在 R 中的不同变量上(R 项目)

python - reshape .cc :55 stretch_dim ! = -1。节点号 X (RESHAPE) 准备失败

python - Windows 上的 Tensorflow for Poets(重新训练 Inception)

python - 有什么方法可以通过 cron 作业在 python 中运行 selenium