Torch for R crashes Rstudio

I am trying to run the example Rmarkdown file in the ISLR textbook which use the fairly new package "torch" which is an interface to the C++ code for torch for deep learning. When I try to run any torch code on my windows laptop it crashes Rstudio. It does do this on my mac laptop.

Also, if I run the .R code in the original R IDE it works ok. But if I run. the .R file in Rstudio it also crashes.

A minimal working example that shows this is

rm(list=ls())
install.packages('torch')
library(torch)
torch_tensor(1:5)

Does anyone else have this issue on Windows 11? Any suggestions to fix it (other than use a Mac, which I do, but my student does not).

1 Like

Facing same issue here in India. Using windows 11 - dell laptop core i7 16GB.

1 Like

I am dealing with the same issue. It started this week, with a code that I previously run normally. Any torch function, or package that use torch (in my case its brulee package), gives a fatal error in R Studio, but not in original R IDE. I'm using the following machine:

Dell Latitude 5430
12th Gen Intel(R) Core(TM) i7-1265U 1.80 GHz
RAM 32,0 GB
Windows 11

1 Like

There is a solution. If you install the developer version it works,

remotes::install_github("mlverse/torch")

it now works. This takes a while to finish, since it is compiling it from source.

The developer has released a new version 0.14.2 so a windows binary version might be CRAN soon. Just check the version number before reinstalling using install.packages("torch").

Glenn

1 Like

Torch working on Rstudio. Thank you for the solution.