|
| 1 | +name: Linux NPU Driver Build |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + os: |
| 6 | + description: 'OS that is used for building in the form of "ubuntu_20_04"' |
| 7 | + type: string |
| 8 | + required: true |
| 9 | + build-runner: |
| 10 | + description: 'Machine on which the builds will run' |
| 11 | + type: string |
| 12 | + required: true |
| 13 | + driver-cmake-options: |
| 14 | + description: 'Custom CMake options for NPU Driver build' |
| 15 | + type: string |
| 16 | + required: false |
| 17 | + build-cache: |
| 18 | + description: 'Whether to take previously built Driver package' |
| 19 | + type: boolean |
| 20 | + required: false |
| 21 | + default: false |
| 22 | + build-cache-key-suffix: |
| 23 | + description: 'Cache package suffix' |
| 24 | + type: string |
| 25 | + required: false |
| 26 | + outputs: |
| 27 | + driver-install-artifact: |
| 28 | + description: 'Driver build package name to be stored as the action artifact' |
| 29 | + value: ${{ jobs.Build.outputs.driver-install-artifact }} |
| 30 | + |
| 31 | +defaults: |
| 32 | + run: |
| 33 | + shell: bash |
| 34 | + |
| 35 | +permissions: read-all |
| 36 | + |
| 37 | +env: |
| 38 | + NPU_DRIVER_INSTALL_DIR: ./npu_driver_install |
| 39 | + NPU_DRIVER_INSTALL_ARTIFACT: l_ov_cid_${{ inputs.os }}_npu_${{ github.sha }} |
| 40 | + |
| 41 | +jobs: |
| 42 | + Cache: |
| 43 | + name: Cache Driver |
| 44 | + if: ${{ inputs.build-cache }} |
| 45 | + runs-on: ubuntu-latest |
| 46 | + outputs: |
| 47 | + cache-hit: ${{ steps.restore.outputs.cache-hit }} |
| 48 | + cache-key: ${{ steps.key.outputs.cache-key }} |
| 49 | + steps: |
| 50 | + - name: Get cache key |
| 51 | + id: key |
| 52 | + run: | |
| 53 | + cache_key="l_ov_cid_${{ inputs.os }}_cache_${{ inputs.build-cache-key-suffix || github.sha }}" |
| 54 | + echo "cache-key=$cache_key" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + - name: Restore Driver package from cache |
| 57 | + id: restore |
| 58 | + uses: actions/cache/restore@v4 |
| 59 | + with: |
| 60 | + key: ${{ steps.key.outputs.cache-key }} |
| 61 | + path: ${{ env.NPU_DRIVER_INSTALL_DIR }} |
| 62 | + |
| 63 | + - name: Upload artifacts |
| 64 | + if: ${{ steps.restore.outputs.cache-hit }} |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + path: ${{ env.NPU_DRIVER_INSTALL_DIR }} |
| 68 | + name: ${{ env.NPU_DRIVER_INSTALL_ARTIFACT }} |
| 69 | + |
| 70 | + Build: |
| 71 | + name: Build Driver |
| 72 | + needs: Cache |
| 73 | + if: ${{ always() && needs.Cache.outputs.cache-hit != 'true' }} |
| 74 | + runs-on: ${{ inputs.build-runner }} |
| 75 | + timeout-minutes: 240 |
| 76 | + outputs: |
| 77 | + driver-install-artifact: ${{ steps.set_artifact_name.outputs.driver-install-artifact }} |
| 78 | + env: |
| 79 | + DEBIAN_FRONTEND: noninteractive |
| 80 | + NPU_ACTIONS_DIR: ./npu_actions |
| 81 | + NPU_COMPILER_REPO: ./npu_compiler |
| 82 | + NPU_DRIVER_REPO: ./npu_driver |
| 83 | + NPU_DRIVER_BUILD_DIR: ./npu_driver_build |
| 84 | + steps: |
| 85 | + - name: Checkout versions action |
| 86 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 87 | + with: |
| 88 | + path: ${{ env.NPU_ACTIONS_DIR }} |
| 89 | + sparse-checkout: | |
| 90 | + .github/actions/versions |
| 91 | + sparse-checkout-cone-mode: false |
| 92 | + |
| 93 | + - name: Get versions |
| 94 | + uses: ./npu_actions/.github/actions/versions |
| 95 | + id: versions |
| 96 | + |
| 97 | + - name: Clone Linux NPU Driver |
| 98 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 99 | + timeout-minutes: 15 |
| 100 | + with: |
| 101 | + repository: intel/linux-npu-driver |
| 102 | + path: ${{ env.NPU_DRIVER_REPO }} |
| 103 | + submodules: true |
| 104 | + |
| 105 | + - name: System info |
| 106 | + uses: openvinotoolkit/openvino/.github/actions/system_info@master |
| 107 | + |
| 108 | + - name: Install system packages |
| 109 | + run: | |
| 110 | + sudo apt update |
| 111 | + sudo apt install -y build-essential git git-lfs cmake libudev-dev libboost-all-dev libssl-dev libtbb12 |
| 112 | +
|
| 113 | + - name: Configure OpenVINO and NPU Compiler versions |
| 114 | + run: | |
| 115 | + sed -i "s|^set(OPENVINO_REPOSITORY .*|set(OPENVINO_REPOSITORY https://github.com/${{ steps.versions.outputs.openvino-repository }})|" ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 116 | + sed -i '/GIT_REPOSITORY/{n;s|https://github.com/openvinotoolkit/npu_plugin.git|https://github.com/${{ steps.versions.outputs.npu-compiler-repository }}.git|}' ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 117 | + sed -i "s|^set(NPU_COMPILER_TAG .*|set(NPU_COMPILER_TAG ${{ steps.versions.outputs.npu-compiler-tag }})|" ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 118 | + sed -i "s|^set(NPU_COMPILER_REVISION .*|set(NPU_COMPILER_REVISION ${{ steps.versions.outputs.npu-compiler-sha }})|" ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 119 | + sed -i "s|^set(NPU_COMPILER_OPENVINO_REVISION .*|set(NPU_COMPILER_OPENVINO_REVISION ${{ steps.versions.outputs.openvino-sha }})|" ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 120 | + cat ${NPU_DRIVER_REPO}/compiler/compiler_source.cmake |
| 121 | +
|
| 122 | + - name: CMake configure - Linux NPU Driver |
| 123 | + run: | |
| 124 | + cmake \ |
| 125 | + ${{ inputs.driver-cmake-options }} \ |
| 126 | + -DENABLE_OPENVINO_PACKAGE=ON \ |
| 127 | + -DENABLE_NPU_COMPILER_BUILD=ON \ |
| 128 | + -DCMAKE_INSTALL_PREFIX=$(realpath ${NPU_DRIVER_INSTALL_DIR}) \ |
| 129 | + -S ${NPU_DRIVER_REPO} \ |
| 130 | + -B ${NPU_DRIVER_BUILD_DIR} |
| 131 | +
|
| 132 | + - name: CMake build - Linux NPU Driver - deb packages |
| 133 | + run: | |
| 134 | + cmake \ |
| 135 | + --build ${NPU_DRIVER_BUILD_DIR} \ |
| 136 | + --parallel $(nproc) \ |
| 137 | + --target package |
| 138 | +
|
| 139 | + - name: Copy packages |
| 140 | + run: | |
| 141 | + mkdir -p ${NPU_DRIVER_INSTALL_DIR}/external |
| 142 | + mkdir -p ${NPU_DRIVER_INSTALL_DIR}/internal |
| 143 | + mv ${NPU_DRIVER_BUILD_DIR}/intel-{level-zero-npu,fw-npu,driver-compiler-npu}*.*deb ${NPU_DRIVER_INSTALL_DIR}/external/ |
| 144 | + mv ${NPU_DRIVER_BUILD_DIR}/*.*deb ${NPU_DRIVER_INSTALL_DIR}/internal/ |
| 145 | +
|
| 146 | + - name: Cache artifacts |
| 147 | + if: ${{ inputs.build-cache }} |
| 148 | + uses: actions/cache/save@v4 |
| 149 | + with: |
| 150 | + path: ${{ env.NPU_DRIVER_INSTALL_DIR }} |
| 151 | + key: ${{ needs.Cache.outputs.cache-key }} |
| 152 | + |
| 153 | + - name: Upload artifacts |
| 154 | + uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + path: ${{ env.NPU_DRIVER_INSTALL_DIR }} |
| 157 | + name: ${{ env.NPU_DRIVER_INSTALL_ARTIFACT }} |
| 158 | + |
| 159 | + - name: Set artifacts name to outputs |
| 160 | + id: set_artifact_name |
| 161 | + run: | |
| 162 | + echo "driver-install-artifact=$NPU_DRIVER_INSTALL_ARTIFACT" >> $GITHUB_OUTPUT |
0 commit comments