无法在R中安装torch。

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

Unable to install torch in R

问题

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

  1. > install.packages("torch")
  2. Installing package into ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2
  3. (as lib is unspecified)
  4. trying URL 'https://cloud.r-project.org/src/contrib/torch_0.9.1.tar.gz'
  5. Content type 'application/x-gzip' length 1609032 bytes (1.5 MB)
  6. ==================================================
  7. downloaded 1.5 MB
  8. * installing *source* package torch ...
  9. ** package torch successfully unpacked and MD5 sums checked
  10. ** using staged installation
  11. ** libs
  12. Renaming init
  13. "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
  14. Rscript execution error: No such file or directory
  15. make: *** [Makevars:8: rename_init] Error 255
  16. ERROR: compilation failed for package torch
  17. * removing ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2/torch
  18. Warning in install.packages :
  19. installation of package torch had non-zero exit status
  20. The downloaded source packages are in
  21. ‘/tmp/Rtmp45QtUs/downloaded_packages

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

  1. > remotes::install_github("mlverse/torch")
  2. Downloading GitHub repo mlverse/torch@HEAD
  3. ─── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────
  4. checking for file ‘/tmp/Rtmp45QtUs/build-b904c9e30/torch/DESCRIPTION ...
  5. preparing torch’:
  6. checking DESCRIPTION meta-information ...
  7. cleaning src
  8. installing the package to process help pages (447ms)
  9. -----------------------------------
  10. installing *source* package torch ...
  11. ** using staged installation
  12. ** libs
  13. *** Skip building lantern.
  14. *** Renaming init
  15. "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
  16. Rscript execution error: No such file or directory
  17. make: *** [Makevars:21: rename_init] Error 255
  18. ERROR: compilation failed for package torch
  19. removing ‘/tmp/RtmpoGaz4F/Rinst1fb117ee0c7e/torch
  20. -----------------------------------
  21. ERROR: package installation failed
  22. Error: Failed to install torch from GitHub:
  23. ! 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:

  1. > install.packages("torch")
  2. Installing package into ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2
  3. (as lib is unspecified)
  4. trying URL 'https://cloud.r-project.org/src/contrib/torch_0.9.1.tar.gz'
  5. Content type 'application/x-gzip' length 1609032 bytes (1.5 MB)
  6. ==================================================
  7. downloaded 1.5 MB
  8. * installing *source* package torch ...
  9. ** package torch successfully unpacked and MD5 sums checked
  10. ** using staged installation
  11. ** libs
  12. Renaming init
  13. "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
  14. Rscript execution error: No such file or directory
  15. make: *** [Makevars:8: rename_init] Error 255
  16. ERROR: compilation failed for package torch
  17. * removing ‘/home/saidm/R/x86_64-pc-linux-gnu-library/4.2/torch
  18. Warning in install.packages :
  19. installation of package torch had non-zero exit status
  20. The downloaded source packages are in
  21. ‘/tmp/Rtmp45QtUs/downloaded_packages

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

  1. > remotes::install_github("mlverse/torch")
  2. Downloading GitHub repo mlverse/torch@HEAD
  3. ── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────
  4. checking for file ‘/tmp/Rtmp45QtUs/build-b904c9e30/torch/DESCRIPTION ...
  5. preparing torch’:
  6. checking DESCRIPTION meta-information ...
  7. cleaning src
  8. installing the package to process help pages (447ms)
  9. -----------------------------------
  10. installing *source* package torch ...
  11. ** using staged installation
  12. ** libs
  13. *** Skip building lantern.
  14. *** Renaming init
  15. "/usr/lib/R/bin/Rscript" "../tools/renameinit.R"
  16. Rscript execution error: No such file or directory
  17. make: *** [Makevars:21: rename_init] Error 255
  18. ERROR: compilation failed for package torch
  19. removing ‘/tmp/RtmpoGaz4F/Rinst1fb117ee0c7e/torch
  20. -----------------------------------
  21. ERROR: package installation failed
  22. Error: Failed to install 'torch' from GitHub:
  23. ! 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 软件包。以下是我使用的命令:

  1. 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:

  1. 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:

确定