Source Code Compilation and Build
Obtain the PyTorch source code, build the CUDA wheel from source code, and install it.
- Obtain the PyTorch 2.11.0 source code.
1 2 3
git clone --recursive --branch v2.11.0 --depth 1 https://github.com/pytorch/pytorch.git cd pytorch git submodule update --init --recursive
- Install the PyTorch build dependencies.
1python3 -m pip install -r requirements.txt
- Build the CUDA wheel from source code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
export CUDA_HOME=/usr/local/cuda-13.0 export PATH=/usr/local/cuda-13.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-13.0/lib64:${LD_LIBRARY_PATH:-} export USE_CUDA=1 export USE_CUDNN=0 export USE_NCCL=0 export USE_DISTRIBUTED=0 export BUILD_TEST=0 export TORCH_CUDA_ARCH_LIST="8.0;8.6;8.9;9.0;10.0;12.0" export MAX_JOBS=8 export PYTORCH_BUILD_VERSION=2.11.0 export PYTORCH_BUILD_NUMBER=1 python3 -m pip wheel --no-build-isolation --no-deps --wheel-dir dist .
The following is an example of the build product.
1torch-2.11.0-cp311-cp311-linux_aarch64.whl
- Install the local build product.
1 2 3 4 5 6
dnf install -y \ --setopt=install_weak_deps=False \ --setopt=tsflags=nodocs \ openblas numactl-libs python3 -m pip install --force-reinstall --no-deps dist/torch-2.11.0-*.whl
Parent topic: Development Guide