Skip to content

Commit 99a4129

Browse files
committed
download prebuilt npu plugin library
1 parent 6343650 commit 99a4129

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed

src/plugins/intel_npu/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set(NPU_PLUGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1818

1919
include(cmake/features.cmake)
2020

21+
if(ENABLE_PLUGIN_COMPILER)
22+
include(cmake/download_compiler_libs.cmake)
23+
endif()
24+
2125
set(CMAKE_CXX_STANDARD 17)
2226

2327
if(ENABLE_NPU_DEBUG_CAPS)
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Copyright (C) 2018-2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
5+
# Function to download and extract files
6+
function(download_and_extract url zip_file extracted_dir modify_proxy)
7+
# Check if the prebuilt Plugin compiler libraries not exist
8+
if(NOT EXISTS "${extracted_dir}")
9+
# Download the prebuilt Plugin compiler libraries, if failure, show error message and exit
10+
if(NOT "${url}" STREQUAL "")
11+
if(modify_proxy STREQUAL "MODIFY")
12+
# Update proxy to enable download for windows url
13+
set(original_NO_PROXY $ENV{NO_PROXY})
14+
set(original_no_proxy $ENV{no_proxy})
15+
set(ENV{NO_PROXY} "")
16+
set(ENV{no_proxy} "")
17+
endif()
18+
19+
message(STATUS "${url} is not empty")
20+
message(STATUS "Downloading prebuilt Plugin compiler libraries from ${url}")
21+
file(DOWNLOAD "${url}" "${zip_file}"
22+
TIMEOUT 3600
23+
LOG log_output
24+
STATUS download_status
25+
SHOW_PROGRESS)
26+
27+
if(modify_proxy STREQUAL "MODIFY")
28+
# Restore proxy
29+
set(ENV{NO_PROXY} ${original_NO_PROXY})
30+
set(ENV{no_proxy} ${original_no_proxy})
31+
endif()
32+
33+
list(GET download_status 0 download_result)
34+
if(NOT download_result EQUAL 0)
35+
message(FATAL_ERROR "Download failed!\nStatus: ${download_status}\nLog: ${log_output}")
36+
else()
37+
message(STATUS "Download completed: ${zip_file}")
38+
endif()
39+
endif()
40+
41+
message(STATUS "Unzipping prebuilt Plugin compiler libraries to ${extracted_dir}")
42+
# Determine extraction method based on file extension
43+
if("${zip_file}" MATCHES "\\.zip$")
44+
file(ARCHIVE_EXTRACT INPUT "${zip_file}" DESTINATION "${extracted_dir}")
45+
elseif("${zip_file}" MATCHES "\\.tar.gz$")
46+
if(NOT EXISTS "${extracted_dir}")
47+
file(MAKE_DIRECTORY "${extracted_dir}")
48+
message(STATUS "Directory ${extracted_dir} created to unzip.")
49+
endif()
50+
execute_process(COMMAND tar -xzf "${zip_file}" -C "${extracted_dir}")
51+
elseif("${zip_file}" MATCHES "\\.deb$")
52+
execute_process(COMMAND dpkg-deb -x "${zip_file}" "${extracted_dir}")
53+
elseif("${zip_file}" MATCHES "\\.exe$")
54+
set(WINRAR_PATHS
55+
"C:/Program Files/WinRAR"
56+
"C:/Program Files (x86)/WinRAR"
57+
)
58+
59+
set(WINRAR_FOUND FALSE)
60+
set(WINRAR_EXECUTABLE "")
61+
62+
foreach(PATH ${WINRAR_PATHS})
63+
if(EXISTS "${PATH}/WinRAR.exe")
64+
set(WINRAR_FOUND TRUE)
65+
set(WINRAR_EXECUTABLE "${PATH}/WinRAR.exe")
66+
break()
67+
endif()
68+
endforeach()
69+
70+
if(WINRAR_FOUND)
71+
message(STATUS "WinRAR found at: ${WINRAR_EXECUTABLE} and extract ${zip_file} to ${extracted_dir}")
72+
file(MAKE_DIRECTORY "${extracted_dir}")
73+
execute_process(
74+
COMMAND "${WINRAR_EXECUTABLE}" x -y -o+ "${zip_file}" "${extracted_dir}"
75+
RESULT_VARIABLE result
76+
OUTPUT_VARIABLE output
77+
ERROR_VARIABLE error
78+
)
79+
80+
if(result EQUAL 0)
81+
message(STATUS "Extraction successful: ${output}")
82+
else()
83+
#file(REMOVE_RECURSE "${extracted_dir}")
84+
message(STATUS "Extraction failed: ${error}")
85+
endif()
86+
else()
87+
message(FATAL_ERROR "WinRAR not found. Please install WinRAR to proceed.")
88+
endif()
89+
else()
90+
message(FATAL_ERROR "Unsupported file extension for extraction: ${zip_file}")
91+
endif()
92+
file(REMOVE "${zip_file}")
93+
else()
94+
message(STATUS "Prebuilt Plugin compiler libraries already exist, skip download")
95+
endif()
96+
endfunction()
97+
98+
if(ENABLE_PLUGIN_COMPILER)
99+
message(STATUS "Downloading prebuilt NPU Plugin compiler libraries")
100+
if(WIN32)
101+
set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/plugin_compiler_lib/win")
102+
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")
103+
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")
104+
set(PLUGIN_COMPILER_LIBS_DIR_UNZIPPED "${PLUGIN_COMPILER_LIBS_DIR}/cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218")
105+
106+
download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_ZIP}" "${PLUGIN_COMPILER_LIBS_DIR_UNZIPPED}" "MODIFY")
107+
set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_UNZIPPED}/cid/lib")
108+
109+
configure_file(
110+
${PLUGIN_COMPILER_LIB_PATH}/npu_driver_compiler.dll
111+
${PLUGIN_COMPILER_LIB_PATH}/openvino_intel_npu_compiler.dll
112+
COPYONLY
113+
)
114+
set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/openvino_intel_npu_compiler.dll")
115+
file(COPY "${PLUGIN_COMPILER_LIB}"
116+
DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
117+
message(STATUS "Not Copying prebuilt Plugin compiler libraries openvino_intel_npu_compiler.dll to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for windows")
118+
else()
119+
# Check if the operating system is Linux and not macOS
120+
if(UNIX AND NOT APPLE)
121+
# Get the OS name and version
122+
execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
123+
execute_process(COMMAND lsb_release -rs OUTPUT_VARIABLE OS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
124+
125+
if(OS_NAME STREQUAL "Ubuntu")
126+
if(OS_VERSION STREQUAL "22.04")
127+
# Ubuntu 22.04-specific settings or actions
128+
set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/compiler_libs/ubuntu22.04")
129+
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")
130+
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")
131+
set(PLUGIN_COMPILER_LIBS_DIR_EXTRACTED "${PLUGIN_COMPILER_LIBS_DIR}/7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_212")
132+
133+
download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_TAR}" "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}" "NONE")
134+
set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}/cid/lib/")
135+
136+
configure_file(
137+
${PLUGIN_COMPILER_LIB_PATH}/libnpu_driver_compiler.so
138+
${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so
139+
COPYONLY
140+
)
141+
set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so")
142+
file(COPY "${PLUGIN_COMPILER_LIB}" DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
143+
message(STATUS "Not Copying prebuilt Plugin compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 22.04")
144+
elseif(OS_VERSION STREQUAL "24.04")
145+
message(STATUS "This is Ubuntu 24.04")
146+
set(PLUGIN_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/temp/compiler_libs/ubuntu24.04")
147+
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")
148+
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")
149+
set(PLUGIN_COMPILER_LIBS_DIR_EXTRACTED "${PLUGIN_COMPILER_LIBS_DIR}/7_4_3-Release_dyntbb_postcommit_cid_a934b15d7494c4961afd51cf6c896b15d1fabd8c_251119_2204")
150+
151+
download_and_extract("${PLUGIN_COMPILER_LIBS_URL}" "${PLUGIN_COMPILER_LIBS_TAR}" "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}" "NONE")
152+
set(PLUGIN_COMPILER_LIB_PATH "${PLUGIN_COMPILER_LIBS_DIR_EXTRACTED}/cid/lib/")
153+
configure_file(
154+
${PLUGIN_COMPILER_LIB_PATH}/libnpu_driver_compiler.so
155+
${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so
156+
COPYONLY
157+
)
158+
set(PLUGIN_COMPILER_LIB "${PLUGIN_COMPILER_LIB_PATH}/libopenvino_intel_npu_compiler.so")
159+
file(COPY "${PLUGIN_COMPILER_LIB}" DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
160+
message(STATUS "Copying prebuilt Plugin compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 24.04")
161+
endif()
162+
else()
163+
message(STATUS "This is a different Linux distribution: ${OS_NAME}, skip downloading prebuilt Plugin compiler libraries. Can not use plugin compiler libraries!")
164+
# Other Linux-specific settings or actions
165+
endif()
166+
endif()
167+
endif()
168+
169+
install(FILES ${PLUGIN_COMPILER_LIB}
170+
DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${NPU_INTERNAL_COMPONENT})
171+
endif()

src/plugins/intel_npu/cmake/features.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ if(NOT ENABLE_NPU_PLUGIN_ENGINE AND ENABLE_TESTS)
1111
endif()
1212

1313
ov_dependent_option(ENABLE_INTEL_NPU_PROTOPIPE "Enable Intel NPU Protopipe tool" ON "ENABLE_INTEL_NPU_INTERNAL" OFF)
14+
15+
ov_option(ENABLE_PLUGIN_COMPILER "Enable VCL for NPU compiler" ON)

0 commit comments

Comments
 (0)