Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/30315 The new structure is that libtorch_cpu contains the bulk of our code, and libtorch depends on libtorch_cpu and libtorch_cuda. This is a reland of https://github.com/pytorch/pytorch/pull/29731 but I've extracted all of the prep work into separate PRs which can be landed before this one. Some things of note: * torch/csrc/cuda/nccl.cpp was added to the wrong list of SRCS, now fixed (this didn't matter before because previously they were all in the same library) * The dummy file for libtorch was brought back from the dead; it was previously deleted in #20774 In an initial version of the patch, I forgot to make torch_cuda explicitly depend on torch_cpu. This lead to some very odd errors, most notably "bin/blob_test: hidden symbol `_ZNK6google8protobuf5Arena17OnArenaAllocationEPKSt9type_infom' in lib/libprotobuf.a(arena.cc.o) is referenced by DSO" * A number of places in Android/iOS builds have to add torch_cuda explicitly as a library, as they do not have transitive dependency calculation working correctly * I had to torch_cpu/torch_cuda caffe2_interface_library so that they get whole-archived linked into torch when you statically link. And I had to do this in an *exported* fashion because torch needs to depend on torch_cpu_library. In the end I exported everything and removed the redefinition in the Caffe2Config.cmake. However, I am not too sure why the old code did it in this way in the first place; however, it doesn't seem to have broken anything to switch it this way. * There's some uses of `__HIP_PLATFORM_HCC__` still in `torch_cpu` code, so I had to apply it to that library too (UGH). This manifests as a failer when trying to run the CUDA fuser. This doesn't really matter substantively right now because we still in-place HIPify, but it would be good to fix eventually. This was a bit difficult to debug because of an unrelated HIP bug, see https://github.com/ROCm-Developer-Tools/HIP/issues/1706 Fixes #27215 (as our libraries are smaller), and executes on part of the plan in #29235. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Differential Revision: D18790941 Pulled By: ezyang fbshipit-source-id: 01296f6089d3de5e8365251b490c51e694f2d6c7 |
||
|---|---|---|
| .. | ||
| appveyor | ||
| fbcode-dev-setup | ||
| model_zoo | ||
| onnx | ||
| add_apache_header.sh | ||
| apache_header.txt | ||
| apache_python.txt | ||
| build_android.sh | ||
| build_host_protoc.sh | ||
| build_ios.sh | ||
| build_local.sh | ||
| build_mobile.sh | ||
| build_pytorch_android.sh | ||
| build_raspbian.sh | ||
| build_tegra_x1.sh | ||
| build_tizen.sh | ||
| build_windows.bat | ||
| diagnose_protobuf.py | ||
| get_python_cmake_flags.py | ||
| proto.ps1 | ||
| read_conda_versions.sh | ||
| README.md | ||
| remove_apache_header.sh | ||
| run_mobilelab.py | ||
| temp.sh | ||
| xcode_build.rb | ||
This directory contains the useful tools.
build_android.sh
This script is to build PyTorch/Caffe2 library for Android. Take the following steps to start the build:
- set ANDROID_NDK to the location of ndk
export ANDROID_NDK=YOUR_NDK_PATH
- run build_android.sh
#in your PyTorch root directory
bash scripts/build_android.sh
If succeeded, the libraries and headers would be generated to build_android/install directory. You can then copy these files from build_android/install to your Android project for further usage.
You can also override the cmake flags via command line, e.g., following command will also compile the executable binary files:
bash scripts/build_android.sh -DBUILD_BINARY=ON
build_ios.sh
This script is to build PyTorch/Caffe2 library for iOS, and can only be performed on macOS. Take the following steps to start the build:
- Install Xcode from App Store, and configure "Command Line Tools" properly on Xcode.
- Install the dependencies:
brew install cmake automake libtool
- run build_ios.sh
#in your PyTorch root directory
bash scripts/build_ios.sh
If succeeded, the libraries and headers would be generated to build_ios/install directory. You can then copy these files to your Xcode project for further usage.