torch icon indicating copy to clipboard operation
torch copied to clipboard

R Session Aborted

Open feifeidrew opened this issue 11 months ago • 20 comments

After i installed torch package, I wanna see if it worked, so i tried "torch_tensor(1:5)" Then it said R Session Aborted. Could anyone help me plz? thanks o(╥﹏╥)o

here's the code:

install.packages("torch") torch::install_torch() library(torch)

torch_tensor(1:5)

feifeidrew avatar Feb 09 '25 15:02 feifeidrew

Thanks for reporting @feifeidrew !

What's your OS? Were there any packages loaded prior to loading torch?

dfalbel avatar Feb 09 '25 23:02 dfalbel

I get the same error on a windows 11 laptop. I am not using any GPU.

I was trying to run the first lab from the ISLR2 textbook and got this crash on windows, but it worked correctly on my MacBook Air laptop.

Then I tried the minimal example above and it also crashed RStudio R Session Aborted.

glennfulford avatar Feb 11 '25 23:02 glennfulford

Thanks for reporting @glennfulford ! What's you RStudio version? In the meantime, please install torch 0.13.

dfalbel avatar Feb 11 '25 23:02 dfalbel

Sorry, I should have said. I am using RStudio version 2024.12.0+467 and R version 4.4.2 (both should be the latest of both.

When it didn't work I also tried to install the development version, but I seemed to be getting a lot of permission errors about not being able to copy dll files, e.g.

problem copying C:\Users\Glenn\AppData\Local\R\win-library\4.4\00LOCK-torch\torch\lib\c10.dll to C:\Users\Glenn\AppData\Local\R\win-library\4.4\torch\lib\c10.dll: Permission denied

torch version 14.4.1.

I will try to install the torch 13.1 version, if I can.

My student also got exactly the same error in his windows machine.

Thanks,
Glenn

glennfulford avatar Feb 12 '25 09:02 glennfulford

Thanks @glennfulford ! Would you be able to also post your sessionInfo() after loading torch? eg:

library(torch)
sessionInfo()

I'm still unable to reproduce in my local Windows machine.

dfalbel avatar Feb 12 '25 10:02 dfalbel

Actually, I was able to reproduce if installing using the pre-built binaries, but not if installing directly from CRAN.

dfalbel avatar Feb 12 '25 10:02 dfalbel

This is my sessInfor() output.

R version 4.4.2 (2024-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale: [1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8
[3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8

time zone: Australia/Brisbane tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] torch_0.14.1 Matrix_1.7-1

loaded via a namespace (and not attached): [1] desc_1.4.3 coro_1.1.0 digest_0.6.37 R6_2.5.1
[5] fastmap_1.2.0 bit_4.5.0.1 xfun_0.50 lattice_0.22-6
[9] magrittr_2.0.3 glue_1.8.0 knitr_1.49 htmltools_0.5.8.1 [13] bit64_4.6.0-1 rmarkdown_2.29 ps_1.8.1 cli_3.6.3
[17] processx_3.8.5 callr_3.7.6 grid_4.4.2 withr_3.0.2
[21] compiler_4.4.2 rstudioapi_0.17.1 tools_4.4.2 evaluate_1.0.3
[25] Rcpp_1.0.14 yaml_2.3.10 rlang_1.1.5

glennfulford avatar Feb 12 '25 15:02 glennfulford

Thanks Daniel, Your comment,

Actually, I was able to reproduce if installing using the pre-built binaries, but not if installing directly from CRAN.

I just want to clarify, do you mean you got it to work by installing from source, e.g.

install.packages("torch_0.14.1.tar.z"), after downloading this file, instead of the usual install.packages("torch") ?

When I tried that I got copy permission errors. Am I supposed to run it in Administrator mode?

I'll try it again after reinstalling R and Rstudio.

glennfulford avatar Feb 12 '25 15:02 glennfulford

I tried the installation from source. It still crashes Rstudio.

glennfulford avatar Feb 12 '25 16:02 glennfulford

To clarify, I doesn't crash for me if I do:

install.packages("torch")
library(torch)
# accept to download additional binaries

It crashes if I run:

options(timeout = 600) # increasing timeout is recommended since we will be downloading a 2GB file.
kind <- "cpu"
version <- "0.14.1"
options(repos = c(
  torch = sprintf("https://torch-cdn.mlverse.org/packages/%s/%s/", kind, version),
  CRAN = "https://cloud.r-project.org" # or any other from which you want to install the other R dependencies.
))
install.packages("torch")

dfalbel avatar Feb 12 '25 16:02 dfalbel

Actually, I was able to reproduce if installing using the pre-built binaries, but not if installing directly from CRAN.nks for the clarifacation.

For me it definitely crashes if I do

install.packages("torch")
library(torch)
# accept to download additional binaries

I thought that was installing the binary version.

I also tried 
install.packages("torch_0.14.1.tar.gz")

after downloading the .gz file from CRAN, and this appeared to compile the source, but it still crashed when I ran torch_tesnsor(1:5)


glennfulford avatar Feb 12 '25 17:02 glennfulford

Hi @glennfulford !

I made a speculative fix on current dev version of torch. It would be nice if you could try it and let me know if this is still an issue:

remotes::install_github("mlverse/torch")

dfalbel avatar Feb 13 '25 18:02 dfalbel

I have the same issue with 0.14.1 CPU version.

sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 [4] LC_NUMERIC=C LC_TIME=German_Germany.utf8

time zone: Europe/Berlin tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] torch_0.14.1

loaded via a namespace (and not attached): [1] desc_1.4.3 coro_1.1.0 R6_2.6.0 bit_4.5.0.1 magrittr_2.0.3 glue_1.8.0
[7] bit64_4.6.0-1 ps_1.8.1 cli_3.6.4 processx_3.8.5 callr_3.7.6 withr_3.0.2
[13] compiler_4.3.0 rstudioapi_0.17.1 tools_4.3.0 Rcpp_1.0.14 rlang_1.1.5

Rstudio has been updated to the latest version and all packages have been updated.

As soon as I call torch_tensor() a crash happens. However, this only happens inside Rstudio. When running Rgui.exe or R from commandline everything is fine. I can run operations on tensors and also the examples form the doc run through.

It must be something with the communication to Rstudio that is causing this behavior.

Bernie-K avatar Feb 14 '25 09:02 Bernie-K

@Bernie-K

Can you install the dev version of torch, using remotes::install_github("mlverse/torch") and see if it fixes the issue?

Thanks!

dfalbel avatar Feb 14 '25 09:02 dfalbel

@dfalbel Thanks, seems to fix the issue. Tested training with luz on the MNIST example. Runs as expected.

Bernie-K avatar Feb 14 '25 10:02 Bernie-K

Cool! I'll submit a new version to CRAN soon.

dfalbel avatar Feb 14 '25 10:02 dfalbel

Using remotes::install_github("mlverse/torch") worked for me also.

glennfulford avatar Feb 14 '25 13:02 glennfulford

I tried remotes::install_github("mlverse/torch"), but is still an issue when running

library(torch) torch_tensor(1:5).

Could anyone help me plz? Has anyone else encountered the same issue?

Here is my detail: `> library(torch)

torch_is_installed() [1] TRUE sessionInfo() R version 4.5.1 (2025-06-13 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 26100)

Matrix products: default LAPACK version 3.12.1

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

time zone: Asia/Shanghai tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] torch_0.16.0.9000

loaded via a namespace (and not attached): [1] processx_3.8.6 bit_4.6.0 compiler_4.5.1 magrittr_2.0.3 cli_3.6.5 tools_4.5.1
[7] rstudioapi_0.17.1 Rcpp_1.1.0 bit64_4.6.0-1 coro_1.1.0 callr_3.7.6 ps_1.9.1
[13] rlang_1.1.6 `

Yafeia avatar Sep 02 '25 14:09 Yafeia

I tried remotes::install_github("mlverse/torch"), but is still an issue when running

library(torch) torch_tensor(1:5).

Could anyone help me plz? Has anyone else encountered the same issue?

Here is my detail: `> library(torch)

torch_is_installed() [1] TRUE sessionInfo() R version 4.5.1 (2025-06-13 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 26100)

Matrix products: default LAPACK version 3.12.1

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8 [3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.utf8

time zone: Asia/Shanghai tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] torch_0.16.0.9000

loaded via a namespace (and not attached): [1] processx_3.8.6 bit_4.6.0 compiler_4.5.1 magrittr_2.0.3 cli_3.6.5 tools_4.5.1 [7] rstudioapi_0.17.1 Rcpp_1.1.0 bit64_4.6.0-1 coro_1.1.0 callr_3.7.6 ps_1.9.1 [13] rlang_1.1.6 `

Yafeia avatar Sep 03 '25 02:09 Yafeia

It runs fine in RGui.

Yafeia avatar Sep 03 '25 02:09 Yafeia