无法在R中安装torch。

huangapple go评论104阅读模式
英文:

Unable to install torch in R

问题

我尝试在R中安装'torch'软件包以构建一些机器学习模型,但出现以下错误:

> install.packages("torch")
Installing package into ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/torch_0.9.1.tar.gz'
Content type 'application/x-gzip' length 1609032 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *source* package ‘torch’ ...
** package ‘torch’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
Renaming init
"/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
Rscript execution error: No such file or directory
make: *** [Makevars:8: rename_init] Error 255
ERROR: compilation failed for package ‘torch’
* removing ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2/torch’
Warning in install.packages :
  installation of package ‘torch’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp45QtUs/downloaded_packages’

我尝试使用' remotes'软件包再次尝试,但仍然出现相同的错误:

> remotes::install_github("mlverse/torch")
Downloading GitHub repo mlverse/torch@HEAD
─── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/tmp/Rtmp45QtUs/build-b904c9e30/torch/DESCRIPTION’ ...
─  preparing ‘torch’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to process help pages (447ms)
         -----------------------------------
─  installing *source* package ‘torch’ ...
   ** using staged installation
   ** libs
   *** Skip building lantern.
   *** Renaming init
   "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
   Rscript execution error: No such file or directory
   make: *** [Makevars:21: rename_init] Error 255
   ERROR: compilation failed for package ‘torch’
─  removing ‘/tmp/RtmpoGaz4F/Rinst1fb117ee0c7e/torch’
         -----------------------------------
   ERROR: package installation failed
Error: Failed to install ‘torch’ from GitHub:
  ! System command ‘R’ failed

是否有人知道如何解决这个问题,或者至少告诉我'Error 255'是什么意思?非常感谢。

英文:

I tried to install the torch package in R in order to build some machine learning models, but it resulted in the following error:

> install.packages("torch")
Installing package into ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/torch_0.9.1.tar.gz'
Content type 'application/x-gzip' length 1609032 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *source* package ‘torch’ ...
** package ‘torch’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
Renaming init
"/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
Rscript execution error: No such file or directory
make: *** [Makevars:8: rename_init] Error 255
ERROR: compilation failed for package ‘torch’
* removing ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2/torch’
Warning in install.packages :
  installation of package ‘torch’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmp45QtUs/downloaded_packages’

I tried again using the package remotes but it still gave me the same error:

> remotes::install_github("mlverse/torch")
Downloading GitHub repo mlverse/torch@HEAD
── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/tmp/Rtmp45QtUs/build-b904c9e30/torch/DESCRIPTION’ ...
─  preparing ‘torch’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to process help pages (447ms)
         -----------------------------------
─  installing *source* package ‘torch’ ...
   ** using staged installation
   ** libs
   *** Skip building lantern.
   *** Renaming init
   "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
   Rscript execution error: No such file or directory
   make: *** [Makevars:21: rename_init] Error 255
   ERROR: compilation failed for package ‘torch’
─  removing ‘/tmp/RtmpoGaz4F/Rinst1fb117ee0c7e/torch’
         -----------------------------------
   ERROR: package installation failed
Error: Failed to install 'torch' from GitHub:
  ! System command 'R' failed

Does anyone know how to solve this issue, or at least tell me what Error 255 means? Thank you very much in advance.

答案1

得分: 0

我成功解决了这个问题,通过使用 Linux 命令行而不是 R 环境来安装 torch 软件包。以下是我使用的命令:

sudo Rscript -e 'install.packages("torch", repos="https://cloud.r-project.org")'
英文:

I managed to solve the problem and install the torch package by simply using the linux command line instead of R environment. Below is the command I used:

sudo Rscript -e 'install.packages("torch", repos="https://cloud.r-project.org")'

huangapple
  • 本文由 发表于 2023年3月7日 17:57:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75660433.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定