-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[NPU]download prebuilt npu plugin library #33129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DanLiu2Intel
wants to merge
4
commits into
openvinotoolkit:master
Choose a base branch
from
DanLiu2Intel:master_download_vcl_library
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+190
−0
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
src/plugins/intel_npu/cmake/download_compiler_libs.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| # Copyright (C) 2018-2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
|
|
||
| # Function to download and extract files | ||
| function(download_and_extract url zip_file extracted_dir modify_proxy) | ||
| # Check if the prebuilt Plugin compiler libraries not exist | ||
| if(NOT EXISTS "${extracted_dir}") | ||
| # Download the prebuilt Plugin compiler libraries, if failure, show error message and exit | ||
| if(NOT "${url}" STREQUAL "") | ||
| if(modify_proxy STREQUAL "MODIFY") | ||
| # Update proxy to enable download for windows url | ||
| set(original_NO_PROXY $ENV{NO_PROXY}) | ||
| set(original_no_proxy $ENV{no_proxy}) | ||
| set(ENV{NO_PROXY} "") | ||
| set(ENV{no_proxy} "") | ||
| endif() | ||
|
|
||
| message(STATUS "${url} is not empty") | ||
| message(STATUS "Downloading prebuilt Plugin compiler libraries from ${url}") | ||
| file(DOWNLOAD "${url}" "${zip_file}" | ||
| TIMEOUT 3600 | ||
| LOG log_output | ||
| STATUS download_status | ||
| SHOW_PROGRESS) | ||
|
|
||
| if(modify_proxy STREQUAL "MODIFY") | ||
| # Restore proxy | ||
| set(ENV{NO_PROXY} ${original_NO_PROXY}) | ||
| set(ENV{no_proxy} ${original_no_proxy}) | ||
| endif() | ||
|
|
||
| list(GET download_status 0 download_result) | ||
| if(NOT download_result EQUAL 0) | ||
| message(FATAL_ERROR "Download failed!\nStatus: ${download_status}\nLog: ${log_output}") | ||
| else() | ||
| message(STATUS "Download completed: ${zip_file}") | ||
| endif() | ||
| endif() | ||
|
|
||
| message(STATUS "Unzipping prebuilt Plugin compiler libraries to ${extracted_dir}") | ||
| # Determine extraction method based on file extension | ||
| if("${zip_file}" MATCHES "\\.zip$") | ||
| file(ARCHIVE_EXTRACT INPUT "${zip_file}" DESTINATION "${extracted_dir}") | ||
| elseif("${zip_file}" MATCHES "\\.tar.gz$") | ||
| if(NOT EXISTS "${extracted_dir}") | ||
| file(MAKE_DIRECTORY "${extracted_dir}") | ||
| message(STATUS "Directory ${extracted_dir} created to unzip.") | ||
| endif() | ||
| execute_process(COMMAND tar -xzf "${zip_file}" -C "${extracted_dir}") | ||
| elseif("${zip_file}" MATCHES "\\.deb$") | ||
| execute_process(COMMAND dpkg-deb -x "${zip_file}" "${extracted_dir}") | ||
| elseif("${zip_file}" MATCHES "\\.exe$") | ||
| set(WINRAR_PATHS | ||
| "C:/Program Files/WinRAR" | ||
| "C:/Program Files (x86)/WinRAR" | ||
| ) | ||
|
|
||
| set(WINRAR_FOUND FALSE) | ||
| set(WINRAR_EXECUTABLE "") | ||
|
|
||
| foreach(PATH ${WINRAR_PATHS}) | ||
| if(EXISTS "${PATH}/WinRAR.exe") | ||
| set(WINRAR_FOUND TRUE) | ||
| set(WINRAR_EXECUTABLE "${PATH}/WinRAR.exe") | ||
| break() | ||
| endif() | ||
| endforeach() | ||
|
|
||
| if(WINRAR_FOUND) | ||
| message(STATUS "WinRAR found at: ${WINRAR_EXECUTABLE} and extract ${zip_file} to ${extracted_dir}") | ||
| file(MAKE_DIRECTORY "${extracted_dir}") | ||
| execute_process( | ||
| COMMAND "${WINRAR_EXECUTABLE}" x -y -o+ "${zip_file}" "${extracted_dir}" | ||
| RESULT_VARIABLE result | ||
| OUTPUT_VARIABLE output | ||
| ERROR_VARIABLE error | ||
| ) | ||
|
|
||
| if(result EQUAL 0) | ||
| message(STATUS "Extraction successful: ${output}") | ||
| else() | ||
| #file(REMOVE_RECURSE "${extracted_dir}") | ||
| message(STATUS "Extraction failed: ${error}") | ||
| endif() | ||
| else() | ||
| message(FATAL_ERROR "WinRAR not found. Please install WinRAR to proceed.") | ||
| endif() | ||
| else() | ||
| message(FATAL_ERROR "Unsupported file extension for extraction: ${zip_file}") | ||
| endif() | ||
| file(REMOVE "${zip_file}") | ||
| else() | ||
| message(STATUS "Prebuilt Plugin compiler libraries already exist, skip download") | ||
| endif() | ||
| endfunction() | ||
|
|
||
| if(ENABLE_PLUGIN_COMPILER_DOWNLOAD) | ||
| message(STATUS "Downloading prebuilt NPU Plugin compiler libraries") | ||
| if(WIN32) | ||
| set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/plugin_compiler_lib/win") | ||
| set(PLUGIN_COMPILER_LIBS_URL "https://github.com/openvinotoolkit/npu_compiler/releases/download/npu_ud_2025_38_rc4/w_vpux_compiler_l0_win-7_4_3-Release_dyntbb_postcommit_cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218.zip") | ||
| set(PLUGIN_COMPILER_LIBS_ZIP "${PLUGIN_COMPILER_LIBS_DIR}/w_vpux_compiler_l0_win-7_4_3-Release_dyntbb_postcommit_cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218.zip") | ||
| set(PLUGIN_COMPILER_LIBS_DIR_UNZIPPED "${PLUGIN_COMPILER_LIBS_DIR}/cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218") | ||
|
|
||
| download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_ZIP}" "${PLUGIN_COMPILER_LIBS_DIR_UNZIPPED}" "MODIFY") | ||
| set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_UNZIPPED}/cid/lib") | ||
|
|
||
| configure_file( | ||
| ${PLUGIN_COMPILER_LIB_PATH}/npu_driver_compiler.dll | ||
| ${PLUGIN_COMPILER_LIB_PATH}/openvino_intel_npu_compiler.dll | ||
| COPYONLY | ||
| ) | ||
| set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/openvino_intel_npu_compiler.dll") | ||
| file(COPY "${PLUGIN_COMPILER_LIB}" | ||
| DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}") | ||
| message(STATUS "Not Copying prebuilt Plugin compiler libraries openvino_intel_npu_compiler.dll to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for windows") | ||
| else() | ||
| # Check if the operating system is Linux and not macOS | ||
| if(UNIX AND NOT APPLE) | ||
| # Get the OS name and version | ||
| execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| execute_process(COMMAND lsb_release -rs OUTPUT_VARIABLE OS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
|
||
| if(OS_NAME STREQUAL "Ubuntu") | ||
| if(OS_VERSION STREQUAL "22.04") | ||
| # Ubuntu 22.04-specific settings or actions | ||
| set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/compiler_libs/ubuntu22.04") | ||
| set(PLUGIN_COMPILER_LIBS_URL "https://github.com/openvinotoolkit/npu_compiler/releases/download/npu_ud_2025_44_rc1/l_vpux_compiler_l0_linux_ubuntu_22_04-7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2122.tar.gz") | ||
| set(PLUGIN_COMPILER_LIBS_TAR "${PLUGIN_COMPILER_LIBS_DIR}/l_vpux_compiler_l0_linux_ubuntu_22_04-7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2122.tar.gz") | ||
| set(PLUGIN_COMPILER_LIBS_DIR_EXTRACTED "${PLUGIN_COMPILER_LIBS_DIR}/7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_212") | ||
|
|
||
| download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_TAR}" "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}" "NONE") | ||
| set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}/cid/lib/") | ||
|
|
||
| configure_file( | ||
| ${PLUGIN_COMPILER_LIB_PATH}/libnpu_driver_compiler.so | ||
| ${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so | ||
| COPYONLY | ||
| ) | ||
| set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so") | ||
| file(COPY "${PLUGIN_COMPILER_LIB}" DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") | ||
| message(STATUS "Not Copying prebuilt Plugin compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 22.04") | ||
| elseif(OS_VERSION STREQUAL "24.04") | ||
| message(STATUS "This is Ubuntu 24.04") | ||
| set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/compiler_libs/ubuntu24.04") | ||
| set(PLUGIN_COMPILER_LIBS_URL "https://github.com/openvinotoolkit/npu_compiler/releases/download/npu_ud_2025_44_rc1/l_vpux_compiler_l0_linux_ubuntu_24_04-7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2204.tar.gz") | ||
| set(PLUGIN_COMPILER_LIBS_TAR "${PLUGIN_COMPILER_LIBS_DIR}/l_vpux_compiler_l0_linux_ubuntu_24_04-7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2204.tar.gz") | ||
| set(PLUGIN_COMPILER_LIBS_DIR_EXTRACTED "${PLUGIN_COMPILER_LIBS_DIR}/7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2204") | ||
|
|
||
| download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_TAR}" "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}" "NONE") | ||
| set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}/cid/lib/") | ||
| configure_file( | ||
| ${PLUGIN_COMPILER_LIB_PATH}/libnpu_driver_compiler.so | ||
| ${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so | ||
| COPYONLY | ||
| ) | ||
| set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so") | ||
| file(COPY "${PLUGIN_COMPILER_LIB}" DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") | ||
| message(STATUS "Copying prebuilt Plugin compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 24.04") | ||
| endif() | ||
| else() | ||
| message(STATUS "This is a different Linux distribution: ${OS_NAME}, skip downloading prebuilt Plugin compiler libraries. Can not use plugin compiler libraries!") | ||
| # Other Linux-specific settings or actions | ||
| endif() | ||
| endif() | ||
| endif() | ||
|
|
||
| install(FILES ${PLUGIN_COMPILER_LIB} | ||
| DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${NPU_INTERNAL_COMPONENT}) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment to show the downloaded compiler version, make this function clearer