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

Cannot install lantern dependencies on aarm64 architecture #1182

Open
bagdaddy opened this issue Jul 22, 2024 · 6 comments
Open

Cannot install lantern dependencies on aarm64 architecture #1182

bagdaddy opened this issue Jul 22, 2024 · 6 comments

Comments

@bagdaddy
Copy link

bagdaddy commented Jul 22, 2024

Hello, whenever I try to install and use torch, it says that I don't have certain dependencies installed (lantern).
I went through all documentation and I still don't get how I can achieve that manually.

When I try to get the physical files for manual installation, I get an error that my architecture is unsupported. I'm running a rocker/rstudio docker container on an M1 Mac computer.

What I tried:

  • installing using install.packages()
  • installing straight from github
  • installing manually, but I can't seem to get a lantern library URL to download it from, because the helper functions simply do not work on my machine. Namely get_install_libs_url() doesn't work on my architecture

When trying to run torch::install_torch() or get_install_libs_url I get the following error:
! Architecture "aarch64" is not supported in this OS.

I looked at the code, is this issue due to me running this in a docker container?
My architecture is aarch64, but the "OS" in the container is ubuntu. How can I work around this?

Maybe someone could point me to how I can download the actual lantern lib or something? I will set the env variables for torch and lantern urls and maybe then it will get installed? I am starting to go crazy over this

@dfalbel
Copy link
Member

dfalbel commented Jul 22, 2024

This is unfortunatelly not a simple task as LibTorch doesn't provide pre-built binaries for aarch64 systems, so you will need to first:

  1. Build LibTorch from source (see instructions here). Make sure to point to the same version as the R package. Point the env var TORCH_HOME and TORCH_PATH to the installation directory.
  2. Make sure you have cmake installed and on the path. Set BUILD_LANTERN=1 before installing torch from source (via github or install.packages(type="source")), this will build lantern from source.

Sorry for the inconvenience about this :(

@bagdaddy
Copy link
Author

bagdaddy commented Jul 22, 2024

Thank you for such a rapid response!

Do you mean to point to the correct python installation? Or do I need to refer to the version of R torch package? The container is running 3.10 python version.

So do I build the binaries using cmake as in the instructions you provided and then set BUILD_LANTERN=1 and run install.packages("torch", type="source')? And that should be it effectively?

@dfalbel
Copy link
Member

dfalbel commented Jul 22, 2024

Sorry, I meant pointing to the correct LibTorch version (currently it's 2.0.1), when building LibTorch from source:

set(TORCH_VERSION "2.0.1")

@bagdaddy
Copy link
Author

Wouldn't the version be decided by the branch name I provide when cloning the pytorch repository? In this case it would be the latest ~2.4, should I set the branch to v2.0.1 instead?

@dfalbel
Copy link
Member

dfalbel commented Jul 22, 2024

Yes, you have to clone from the tag v2.0.1 in order to get the correct LibTorch version.

@bagdaddy
Copy link
Author

bagdaddy commented Jul 22, 2024

Unfortunately I'm getting this error when building the sources:

CMake Error at cmake/Dependencies.cmake:1088 (if):
  if given arguments:

    "VERSION_LESS" "3"

I tried using this to fix these errors, https://github.com/shanemcandrewai/pytorch-setup?tab=readme-ov-file, but it's not compatible with 2.0.1

Also, when I tried cloning from the main branch I didn't get these errors and I managed to run all of the steps successfully... It's when I tried to downgrad it stopped working

Torch 2.0.1 is compatible with python3.10, so I'm unsure what's wrong.

Edit: Somehow managed to build the sources using the pytorch-setup CMakeFile.txt in the link above, but now I get this output (but I'm guessing this is because removing that stuff before doesn't really fix anything):

* installing *source* package ‘torch’ ...
** package ‘torch’ successfully unpacked and MD5 sums checked
** using staged installation
CMAKE_FLAGS: 
** libs
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
*** Building lantern!
mkdir -p ../build-lantern
cd ../build-lantern && cmake ../src/lantern -DCMAKE_INSTALL_PREFIX=/usr/local/lib/R/site-library/00LOCK-torch/00new/torch -DCMAKE_INSTALL_MESSAGE="LAZY"  && cmake --build . --target install --config Release
CMake Error: The source directory "/tmp/RtmpiNfdV5/R.INSTALL1f944316e37f/torch/src/lantern" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** [Makevars:14: lantern] Error 1
ERROR: compilation failed for package ‘torch’
* removing ‘/usr/local/lib/R/site-library/torch’
* restoring previous ‘/usr/local/lib/R/site-library/torch’

The downloaded source packages are in
	‘/tmp/RtmpcYGbOv/downloaded_packages’
Warning message:
In install.packages("torch", type = "source") :
  installation of package ‘torch’ had non-zero exit status

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

2 participants