Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R Session Aborted #1273

Open
feifeidrew opened this issue Feb 9, 2025 · 17 comments
Open

R Session Aborted #1273

feifeidrew opened this issue Feb 9, 2025 · 17 comments

Comments

@feifeidrew
Copy link

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)

@dfalbel
Copy link
Member

dfalbel commented Feb 9, 2025

Thanks for reporting @feifeidrew !

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

@glennfulford
Copy link

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.

@dfalbel
Copy link
Member

dfalbel commented Feb 11, 2025

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

@glennfulford
Copy link

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

@dfalbel
Copy link
Member

dfalbel commented Feb 12, 2025

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
Copy link
Member

dfalbel commented Feb 12, 2025

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

@glennfulford
Copy link

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
Copy link

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
Copy link

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

@dfalbel
Copy link
Member

dfalbel commented Feb 12, 2025

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")

@glennfulford
Copy link

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)


@dfalbel
Copy link
Member

dfalbel commented Feb 13, 2025

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")

@Bernie-K
Copy link

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.

@dfalbel
Copy link
Member

dfalbel commented Feb 14, 2025

@Bernie-K

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

Thanks!

@Bernie-K
Copy link

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

@dfalbel
Copy link
Member

dfalbel commented Feb 14, 2025

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

@glennfulford
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants