我要评分
获取效率
正确性
完整性
易理解

Source Code Compilation and Build

Obtain the PyTorch source code, build the CUDA wheel from source code, and install it.

  1. 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
    
  2. Install the PyTorch build dependencies.
    1
    python3 -m pip install -r requirements.txt
    
  3. 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.

    1
    torch-2.11.0-cp311-cp311-linux_aarch64.whl
    
  4. 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