-
Notifications
You must be signed in to change notification settings - Fork 74
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
First call to a torch function causes R to crash. #1277
Comments
Also reported in #1273 Could you please install torch from GitHub and see if the speculative fix solves your issue.
So sorry for the disruption |
Thanks. I tried that but the problem persists. I also tried to reinstall associated packages (ps, cli, jsonlite etc), but those reinstalls failed too
|
Does this error also happens when running outside of RStudio? |
Also just to confirm, It's not supported to load both |
In ’native’ R, this sequence worked:
install.packages("torch") # had to install processx separately
library(torch)
sample_data <- matrix(1:10, nrow = 2, ncol = 5) # Simple data
sample_data_tensor <- torch::torch_tensor(sample_data)
So maybe the problem is in RStudio?
|
I believe there's a binary incompatibility between torch and RStudio. I've tried to fix in the current dev version, but it seems it did not fix your problem right? I'm not sure what that could be. Could you perhaps try installing a pre-built R binary using:
And see if this fixes the issue in RStudio too? |
Hi, |
Glad it worked for you @jmlanchy ! Sorry for the disruption! |
Unfortunately it did not work for me. I got errors such as these from native R, and similarly from RStudio.
These problems appeared to start after installing huggingfaceR. Could that be related?
```
trying URL 'https://torch-cdn.mlverse.org/packages/cpu/0.14.1.9000/src/contrib/torch_0.14.1.9000_R_x86_64-pc-linux-gnu.tar.gz'
Content type 'application/x-tar' length 243466894 bytes (232.2 MB)
downloaded 232.2 MB
Warning in untar2(tarfile, files, list, exdir, restore_times) :
failed to copy 'torch/lib/ld-2.31.so' to 'torch/lib/ld-linux-x86-64.so.2'
Warning in untar2(tarfile, files, list, exdir, restore_times) :
failed to copy 'torch/lib/libpthread-2.31.so' to 'torch/lib/libpthread.so.0'
Warning in untar2(tarfile, files, list, exdir, restore_times) :
restoring symbolic link as a file copy
* installing *binary* package 'torch' ...
cp: unknown option -- )
Try '/c/RBUILD~1/4.3/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/dell/AppData/Local/R/win-library/4.3/torch'
The downloaded source packages are in
‘C:\Users\dell\AppData\Local\Temp\RtmpaIIMcG\downloaded_packages’
Warning message:
In install.packages("torch") :
installation of package ‘torch’ had non-zero exit status
```
|
There's something weird indeed. The first time you reported working on a Windows machine, but it's trying to download a |
I don't know what that could be. I think I'd close all R sessions. Start a clear R session and try the installation, before loading any other package. Next test if torch works standalone. We can then see if there's any bad interaction with other packages such as huggingfaceR - which is likely if they endup loading torch using reticulate. |
Yes, it’s windows 11. I just noticed the linux reference in the error messages.
|
Finally it works! I did this (Rstudio):
1. Uninstalled huggingfaceR
2. Deleted the package installation in C:\Users\dell\AppData\Local\R\win-library\4.3\torch\libs\x64 which was read-only, and I could not set to read/write.
3. Installed the dev version remotes::install_github("mlverse/torch"). Associated files had to be downloaded, so that part was a bit slow.
4. Library(torch) # as usual
5. Then ran sample_data <- matrix(1:10, nrow = 2, ncol = 5) # Simple data
sample_data_tensor <- torch_tensor(sample_data)
Many thanks for your help
(Issue #1277)
I don't know what that could be. I think I'd close all R sessions. Start a clear R session and try the installation, before loading any other package. Next test if torch works standalone. We can then see if there's any bad interaction with other packages such as huggingfaceR - which is likely if they endup loading torch using reticulate.
—
Reply to this email directly, view it on GitHub <#1277 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/BO4ES6MHIIB5U3V6LWXDWI32PUDB5AVCNFSM6AAAAABXC2WPK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJXG4YTSNBWGY> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/BO4ES6NQA4DCYU3L6NC4TCT2PUDB5A5CNFSM6AAAAABXC2WPK2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTU6NGKKU.gif> Message ID: < ***@***.***> ***@***.***>
<https://avatars.githubusercontent.com/u/4706822?s=20&v=4> dfalbel left a comment (mlverse/torch#1277) <#1277 (comment)>
I don't know what that could be. I think I'd close all R sessions. Start a clear R session and try the installation, before loading any other package. Next test if torch works standalone. We can then see if there's any bad interaction with other packages such as huggingfaceR - which is likely if they endup loading torch using reticulate.
—
Reply to this email directly, view it on GitHub <#1277 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/BO4ES6MHIIB5U3V6LWXDWI32PUDB5AVCNFSM6AAAAABXC2WPK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJXG4YTSNBWGY> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/BO4ES6NQA4DCYU3L6NC4TCT2PUDB5A5CNFSM6AAAAABXC2WPK2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTU6NGKKU.gif> Message ID: < ***@***.***> ***@***.***>
|
Awesome! Glad it worked! |
It worked for me too, thanks! @dfalbel |
First call to a torch function causes R to crash. I re-installed torch but the problem persists. No other packages were loaded.
Can anybody help, please. Thanks
System Information:
rTorch: v 0.4.2
Problem:
I am encountering an issue where calling torch_tensor() causes R to crash. Here is a minimal example that reproduces the issue:
Install and load torch library
install.packages("torch") # this is the only package loaded
library(torch)
Ensure Lantern is loaded
torch::torch_manual_seed(42)
Create a minimal tensor
sample_data <- matrix(1:10, nrow = 2, ncol = 5) # Simple data
sample_data_tensor <- torch_tensor(sample_data, dtype = torch_long()) #!!!!!!! CRASH here
The text was updated successfully, but these errors were encountered: