Unable to install torch in R

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/RtmpsYvcmH/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/RtmpsYvcmH/build-a272b1484be/torch/DESCRIPTION’ ...
─  preparing ‘torch’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  installing the package to process help pages (445ms)
         -----------------------------------
─  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/RtmpyWng8n/Rinstcd42226247c/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.

I fixed the problem by simply installing the package from the linux command line instead of R environment, like this:

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

1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.