onnxruntime/docs/build/training.md
PeixuanZuo 97b1115a59
[ROCm] Update doc for ROCm 5.4 (#14494)
### Description
1. Delete preview label for ROCm/MIGraphX and update ROCm/MIGraphX
supported architecture. https://peixuanzuo.github.io/onnxruntime/
2. Update rocm training guide to ROCm5.4.
https://peixuanzuo.github.io/onnxruntime/docs/build/training.html#gpu--rocm
2023-01-31 17:28:11 -08:00

3.6 KiB

title parent description nav_order redirect_from
Build for training Build ONNX Runtime Learn how to build ONNX Runtime for training from source for different hardware targets 2 /docs/how-to/build/training

Build ONNX Runtime for training

{: .no_toc }

Contents

{: .no_toc }

  • TOC placeholder {:toc}

CPU

Build Instructions

{: .no_toc }

To build ORT with training support add --enable_training build instruction.

All other build options are the same for inferencing as they are for training.

Windows

.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --enable_training

The default Windows CMake Generator is Visual Studio 2017, but you can also use the newer Visual Studio 2019 by passing --cmake_generator "Visual Studio 16 2019" to .\build.bat

Linux/macOS

./build.sh --config RelWithDebInfo --build_shared_lib --parallel --enable_training

GPU / CUDA

Prerequisites

{: .no_toc }

The default NVIDIA GPU build requires CUDA runtime libraries installed on the system:

These dependency versions should reflect what is in the Dockerfiles.

Build instructions

{: .no_toc }

  1. Checkout this code repo with git clone https://github.com/microsoft/onnxruntime

  2. Set the environment variables: adjust the path for location your build machine

    export CUDA_HOME=<location for CUDA libs> # e.g. /usr/local/cuda
    export CUDNN_HOME=<location for cuDNN libs> # e.g. /usr/local/cuda
    export CUDACXX=<location for NVCC> #e.g. /usr/local/cuda/bin/nvcc
    export PATH=<location for openmpi/bin/>:$PATH
    export LD_LIBRARY_PATH=<location for openmpi/lib/>:$LD_LIBRARY_PATH
    export MPI_CXX_INCLUDE_PATH=<location for openmpi/include/>
    
  3. Create the ONNX Runtime wheel

    • Change to the ONNX Runtime repo base folder: cd onnxruntime
    • Run ./build.sh --enable_training --use_cuda --config=RelWithDebInfo --build_wheel

    This produces the .whl file in ./build/Linux/RelWithDebInfo/dist for ONNX Runtime Training.

GPU / ROCm

Prerequisites

{: .no_toc }

The default AMD GPU build requires ROCm software toolkit installed on the system:

Build instructions

{: .no_toc }

  1. Checkout this code repo with git clone https://github.com/microsoft/onnxruntime

  2. Create the ONNX Runtime wheel

    • Change to the ONNX Runtime repo base folder: cd onnxruntime
    • Run ./build.sh --config Release --enable_training --build_wheel --parallel --skip_tests --use_rocm --rocm_home /opt/rocm --nccl_home /opt/rocm --mpi_home <location for openmpi>

    This produces the .whl file in ./build/Linux/Release/dist for ONNX Runtime Training.

DNNL and MKLML

Build Instructions

{: .no_toc }

Linux

./build.sh --enable_training --use_dnnl

Windows

.\build.bat --enable_training --use_dnnl

Add --build_wheel to build the ONNX Runtime wheel.

This will produce a .whl file in build/Linux/RelWithDebInfo/dist for ONNX Runtime Training.