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

Arm64 Support For Pytorch? #1174

Open
jxtps opened this issue Apr 19, 2022 · 15 comments
Open

Arm64 Support For Pytorch? #1174

jxtps opened this issue Apr 19, 2022 · 15 comments

Comments

@jxtps
Copy link
Contributor

jxtps commented Apr 19, 2022

I noticed that org.bytedeco CUDA now contains cuda-11.6-8.3-1.5.7-linux-arm64-redist.jar, so it sounds like you've compiled CUDA to run on arm64?

Any chance of also compiling pytorch for arm64 (ideally both for CPU and GPU)?

That would enable using e.g. AWS G5g instances: https://aws.amazon.com/ec2/instance-types/g5g/

Thanks!

@saudet
Copy link
Member

saudet commented Apr 20, 2022

I'm sure there's some way to get that working, we just need to spend some time on it. As usual, contributions are welcome!

@jxtps
Copy link
Contributor Author

jxtps commented Apr 20, 2022

Ok, so there's a smattering of resources out there referencing various builds for various ARM architectures:

  1. https://discuss.pytorch.org/t/crosscompilation-for-arm64/9885/9
    2. Leads to: https://gist.github.com/soumith/45f61db3379db67414814ad9d5f2a427 - a gist, "Install PyTorch on NVIDIA AGX Xavier using JetPack 4.1"
    3. Leads to https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048 - NVIDIA Jetson (an ARM computer) pytorch pip wheels with Build From Source instructions.
  2. https://nmilosev.svbtle.com/compling-arm-stuff-without-an-arm-board-build-pytorch-for-the-raspberry-pi - Build PyTorch for the Raspberry Pi
  3. https://github.com/KumaTea/pytorch-aarch64 - PyTorch, vision, audio, text and csprng wheels (whl) and docker images for aarch64 / ARMv8 / ARM64 devices
  4. https://mathinf.eu/pytorch/arm64/ - PyTorch packages for ARM64. Jetson Build with CUDA. At the Developers Day, PyTorch announced the availability of official ARM64 packages for the nightly (development version) builds.
  5. https://schweter.eu/2017/11/pytorch-arm64.html - PyTorch on ARM64 (no CUDA)
  6. https://qengineering.eu/install-pytorch-on-raspberry-pi-4.html - This page will guide you through the installation of PyTorch 1.11.0, or an earlier version, TorchVision, LibTorch and Caffe2 on a Raspberry Pi 4 with a 64-bit operating system.

@saudet
Copy link
Member

saudet commented Apr 20, 2022

There's no official guide, so we have to spend a bit of time modifying the build script...

@saudet
Copy link
Member

saudet commented May 3, 2022

@frankfliu @zachgk @lanking520 How important are ARM builds for Amazon?

@jxtps See discussion deepjavalibrary/djl#1550 for some context

@lanking520
Copy link

@saudet not sure for Amazon, but we do have some customers in DJL are looking for support on that.

@jxtps
Copy link
Contributor Author

jxtps commented Aug 2, 2022

It looks like PyTorch is publishing ARM wheels and have been for some time: pytorch/pytorch#53357

If you search for "aarch64" on https://download.pytorch.org/whl/torch_stable.html it looks like recent versions are all there.

Could whatever build scripts they're using to produce those wheels help here?

@lanking520
Copy link

DJL has already published AARCH64 for PyTorch: http://docs.djl.ai/engines/pytorch/pytorch-engine/index.html#for-aarch64-build

@jxtps
Copy link
Contributor Author

jxtps commented Aug 2, 2022

Does that include GPU support, e.g. for use with the AWS G5g instance type?

@saudet
Copy link
Member

saudet commented Aug 3, 2022

Could whatever build scripts they're using to produce those wheels help here?

If it can cross compile, we can integrate that right away.

@jxtps
Copy link
Contributor Author

jxtps commented Aug 3, 2022

Nevermind, now that I look closer at https://download.pytorch.org/whl/torch_stable.html they don't have anything cross-compiled for cuda (cu113, cu100 etc), it's all just for cpu. I take it that's not helpful here?

@saudet
Copy link
Member

saudet commented Aug 4, 2022

The CUDA builds also compile the libraries for CPU, so we'll need to get that working first anyway.

@jxtps
Copy link
Contributor Author

jxtps commented Aug 4, 2022

Ok, the main project for the build scripts appears to be: https://github.com/pytorch/builder

Of particular relevance:

There are multiple scripts in there. From what I can tell build_all_docker.sh -> build_docker.sh -> [invoke docker]. The various Dockerfiles then take a myriad of actions and perform the actual builds using various scripts that I haven't deciphered.

@saudet
Copy link
Member

saudet commented Aug 7, 2022

Thanks! I'm not seeing anything about cross compiling for linux-arm64 though. They seem to be building everything on ARM hardware, just like DJL does, but unfortunately, I don't have the resources of Amazon and Facebook, like these guys do, to do builds on ARM hardware.

@lanking520
Copy link

You can try to use Mac OS docker build to build ARM64, or use ARM simulator to initiate docker build

@saudet
Copy link
Member

saudet commented Aug 7, 2022 via email

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

No branches or pull requests

3 participants