Error installing/using torch library

Trying to use the torch library, but the following error shows up:

library(torch)

trying URL 'https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-1.9.0%2Bcpu.zip'
Content type 'application/zip' length 203602338 bytes (194.2 MB)
downloaded 194.2 MB

trying URL 'https://storage.googleapis.com/torch-lantern-builds/refs/heads/cran/v0.6.0/latest/Windows-cpu.zip'
Content type 'application/zip' length 1726568 bytes (1.6 MB)
downloaded 1.6 MB

Warning message:
Failed to install Torch, manually run install_torch().
C:\Users...\Documents\R\win-library\4.1\torch\deps\lantern.dll - %1 is not a valid Win32 application.

Looks like an issue with underlying dependencies for the package. Consider installing PyTorch outside of RStudio and then try reinstalling the R package and see if that makes a difference.

Pytorch was already installed using conda in an environment via:

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

This topic was automatically closed 21 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.

It seems that you are using 32 Bit version of R and that's why it's not working.
Switching to the 64bit version should make it work.