From 19b5e16da32cc93e2687ac0857cf3ba79f0aea70 Mon Sep 17 00:00:00 2001 From: Devasena Kirthika S Date: Mon, 6 May 2024 12:18:22 +0000 Subject: [PATCH] [ZENDNN FWK] Add build from source file Signed-off-by: Devasena Kirthika S Change-Id: Ib95c3a7316b29e0f1aad3381afc575fcb96f7900 Signed-off-by: Devasena Kirthika S Reviewed-on: https://gerrit-git.amd.com/c/amd/ec/ZenDNN_ONNXRuntime/+/1050801 Reviewed-by: Ajeet Singh Reviewed-by: Pratap Gadi Reviewed-by: Chandra Kumar Ramasamy Tested-by: Llvm Cpu (cherry picked from commit 6509ffb53d3abac09925449069b3354562f98519) Reviewed-on: https://gerrit-git.amd.com/c/amd/ec/ZenDNN_ONNXRuntime/+/1052177 Tested-by: Kiriti Pendyala --- BUILD_SOURCE.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 BUILD_SOURCE.md diff --git a/BUILD_SOURCE.md b/BUILD_SOURCE.md new file mode 100644 index 0000000000..5992b9a334 --- /dev/null +++ b/BUILD_SOURCE.md @@ -0,0 +1,52 @@ + +**`Documentation`** | +------------------- | +To build ONNXRUNTIME with ZenDNN follow below steps. + +## Build From Source +### Setup for Linux +Create and activate a conda environment +``` +$ conda create -n onnxrt-v1.17.0-zendnn-4.2-rel-env python=3.8 -y +$ conda activate onnxrt-v1.17.0-zendnn-4.2-rel-env +``` +Install necessary dependencies +``` +$ pip install -U cmake numpy==1.24.4 protobuf==3.20.2 onnx==1.15.0 pytest +$ pip install psutil coloredlogs torch==2.1.2 torchvision transformers==4.39.3 sympy +``` + +### Download the AMD ZenDNN ONNXRUNTIME source code +Location of AMD ZenDNN ONNXRUNTIME: [AMD ZenDNN ONNXRUNTIME](https://github.com/amd/ZenDNN-onnxruntime). + +Checkout AMD ZenDNN ONNXRUNTIME +``` +$ git clone https://github.com/amd/ZenDNN-onnxruntime.git +$ cd ZenDNN-onnxruntime +``` + +The repo defaults to the main development branch which doesn't have ZenDNN support. You need to check out a release branch to build, e.g. `rel-1.17.0_zendnn_rel`. +``` +$ git checkout branch_name # rel-1.17.0_zendnn_rel. +``` + +### Set environment variables +Set environment variables for optimum performance. Some of the environment variables are for housekeeping purposes and can be ignored. +``` +$ source scripts/zendnn_ONNXRT_env_setup.sh +``` + +### Build and install the pip package +Ensure that you install the ONNX Runtime-ZenDNN package corresponding to the Python version with which you created the conda environment. +``` +$ ./build.sh --config Release --build_shared_lib --parallel --use_zendnn --build_wheel --use_openmp --skip_onnx_tests +$ pip install --force-reinstall ./build/Linux/Release/dist/<*.whl> +$ pip install --force protobuf==3.20.2 +``` + +### Quick verification of Build. You should see ZendnnExecutionProvider and ONNXRuntime version +### Change directory to parent folder +``` +$ cd ../ +$ python -c 'import onnxruntime as ort; print("\nONNXRuntime version : ", ort.__version__); print("\nAvailable Execution Providers : ", ort.get_available_providers())' +```