diff --git a/modules/nvidia_plugin/README.md b/modules/nvidia_plugin/README.md
index 3cdbd8dbb..ede223ac4 100644
--- a/modules/nvidia_plugin/README.md
+++ b/modules/nvidia_plugin/README.md
@@ -48,7 +48,7 @@ Afterwards plugin build procedure is as following:
1. Clone `openvino_contrib` repository:
```bash
-git clone --recurse-submodules --single-branch --branch=2022.3.0 https://github.com/openvinotoolkit/openvino_contrib.git
+git clone --recurse-submodules --single-branch --branch=2024.1.0 https://github.com/openvinotoolkit/openvino_contrib.git
```
2. Go to plugin directory:
```bash
@@ -60,7 +60,7 @@ mkdir build && cd build
```
4. Build plugin
- First of all, switch OpenVINO™ to tag _2022.3.0_ and then build it according the instruction [How to build](https://github.com/openvinotoolkit/openvino/wiki#how-to-build)
+ First of all, switch OpenVINO™ to tag _2024.1.0_ and then build it according the instruction [How to build](https://github.com/openvinotoolkit/openvino/wiki#how-to-build)
Then build CUDA Plugin with one of 2 options:
- Using `build.sh`
@@ -97,7 +97,7 @@ If python available the CUDA Plugin could be compiled with setup.py script as fo
1. Clone `openvino_contrib` repository:
```bash
-git clone --recurse-submodules --single-branch --branch=2022.3.0 https://github.com/openvinotoolkit/openvino_contrib.git
+git clone --recurse-submodules --single-branch --branch=2024.1.0 https://github.com/openvinotoolkit/openvino_contrib.git
```
2. Go to plugin directory:
```bash
diff --git a/modules/nvidia_plugin/build.sh b/modules/nvidia_plugin/build.sh
index d6df2bf62..bb7ed5695 100755
--- a/modules/nvidia_plugin/build.sh
+++ b/modules/nvidia_plugin/build.sh
@@ -39,6 +39,7 @@ fi
cd "${OPENVINO_BUILD_PATH}"
cmake "${OPENVINO_HOME}" \
-DENABLE_NVIDIA=ON \
+ -DENABLE_PLUGINS_XML=ON \
-DENABLE_TESTS="${ENABLE_TESTS}" \
-DBUILD_arm_plugin=OFF \
-DBUILD_java_api=OFF \
diff --git a/modules/nvidia_plugin/wheel/openvino_nvidia/__init__.py b/modules/nvidia_plugin/wheel/packages/openvino_nvidia/__init__.py
similarity index 98%
rename from modules/nvidia_plugin/wheel/openvino_nvidia/__init__.py
rename to modules/nvidia_plugin/wheel/packages/openvino_nvidia/__init__.py
index d93b08752..65a934439 100644
--- a/modules/nvidia_plugin/wheel/openvino_nvidia/__init__.py
+++ b/modules/nvidia_plugin/wheel/packages/openvino_nvidia/__init__.py
@@ -36,4 +36,4 @@ def _register_nvidia_plugin():
_register_nvidia_plugin()
-__version__ = "2022.3.0"
+__version__ = "2024.1.0"
diff --git a/modules/nvidia_plugin/wheel/requirements.txt b/modules/nvidia_plugin/wheel/requirements.txt
index a6fcf5fa4..0a7261aae 100644
--- a/modules/nvidia_plugin/wheel/requirements.txt
+++ b/modules/nvidia_plugin/wheel/requirements.txt
@@ -1 +1 @@
-openvino==2022.3.0
+openvino==2024.1.0
diff --git a/modules/nvidia_plugin/wheel/setup.py b/modules/nvidia_plugin/wheel/setup.py
index 2b6b97934..1f4e11aae 100644
--- a/modules/nvidia_plugin/wheel/setup.py
+++ b/modules/nvidia_plugin/wheel/setup.py
@@ -13,9 +13,11 @@
import errno
import multiprocessing
import typing
+import sysconfig
import defusedxml.ElementTree as ET
from defusedxml import defuse_stdlib
+from textwrap import dedent
from pathlib import Path
from setuptools import setup
from setuptools.command.build_clib import build_clib
@@ -39,13 +41,15 @@
PACKAGE_NAME = config('WHEEL_PACKAGE_NAME', 'openvino-nvidia')
OPENVINO_REPO_URI = config('OPENVINO_REPO_DOWNLOAD_URL', 'https://github.com/openvinotoolkit/openvino.git')
-WHEEL_VERSION = config('WHEEL_VERSION', '2022.3.0')
+WHEEL_VERSION = config('WHEEL_VERSION', "2024.1.0")
OPENVINO_REPO_TAG = config('OPENVINO_REPO_TAG', WHEEL_VERSION)
NVIDIA_PLUGIN_CMAKE_TARGET_NAME = 'openvino_nvidia_gpu_plugin'
LIBS_RPATH = '$ORIGIN' if sys.platform == 'linux' else '@loader_path'
OPENVINO_INSTALL_BUILD_DEPS_SCRIPT = "install_build_dependencies.sh"
openvino_src_dir: Optional[str] = None
+build_configuration_name: Optional[str] = None
+package_data: typing.Dict[str, list] = {}
def is_tool(name):
@@ -204,9 +208,11 @@ def finalize_options(self):
super().finalize_options()
global openvino_src_dir
+ global build_configuration_name
+
self.git_exec = shutil.which("git")
self.cmake_exec = shutil.which("cmake")
- self.build_configuration_name = 'Debug' if self.debug else 'Release'
+ build_configuration_name = 'Debug' if self.debug else 'Release'
self.nvidia_plugin_src_dir = os.path.abspath(os.path.dirname(__file__))
self.build_lib_dir = os.path.join(self.nvidia_plugin_src_dir, "../build/lib")
self.openvino_contrib_src_dir = os.path.normpath(os.path.join(self.nvidia_plugin_src_dir, "../../.."))
@@ -226,8 +232,14 @@ def run(self):
if self.cmake_exec is None:
raise FileNotFoundError("cmake path not located on path")
- self.mkpath(self.deps_dir)
self.clone_openvino_src()
+ # TODO: Uncomment when issue with conan dependecies will be resolved.
+ # When uncomment this line, got the following error during
+ # cmake configuration step:
+ # CMake Error at build/protobuf-Target-release.cmake:74 (set_property):
+ # set_property can not be used on an ALIAS target.
+ # ...
+ # self.openvino_conan_install()
self.configure_openvino_cmake()
if self.force:
self.build_openvino()
@@ -235,6 +247,8 @@ def run(self):
self.locate_built_lib()
def clone_openvino_src(self):
+ self.mkpath(self.deps_dir)
+
if os.path.isdir(self.openvino_src_dir):
return
self.announce("Cloning the OpenVINO sources", level=3)
@@ -246,16 +260,40 @@ def clone_openvino_src(self):
cwd=self.openvino_src_dir,
on_fail_msg='Failed to update the OpenVINO git submodules')
+ def openvino_conan_install(self):
+ if not os.path.isdir(self.openvino_build_dir):
+ self.mkpath(self.openvino_build_dir)
+
+ run_command(["conan",
+ "install",
+ f'-of={self.openvino_build_dir}',
+ '--build=missing',
+ self.openvino_src_dir],
+ cwd=self.openvino_build_dir,
+ on_fail_msg='Failed to install conan dependecies for OpenVINO CMake Project')
+
def configure_openvino_cmake(self):
if not os.path.isdir(self.openvino_build_dir):
self.mkpath(self.openvino_build_dir)
- configure_command = [self.cmake_exec, f'-S{self.openvino_src_dir}', f'-B{self.openvino_build_dir}',
- f'-DCMAKE_BUILD_TYPE={self.build_configuration_name}',
+ python_include_dir = sysconfig.get_path("include")
+ configure_command = [self.cmake_exec,
+ '-G', 'Unix Makefiles',
+ f'-S{self.openvino_src_dir}',
+ f'-B{self.openvino_build_dir}',
+ '-DENABLE_PLUGINS_XML=ON',
+ '-DCMAKE_VERBOSE_MAKEFILE=ON',
+ '-DENABLE_NVIDIA=ON',
'-DENABLE_PYTHON=ON',
+ f'-DPython3_EXECUTABLE={sys.executable}',
+ f'-DPython3_INCLUDE_DIR={python_include_dir}',
f'-DPYTHON_EXECUTABLE={sys.executable}',
- f'-DWHEEL_VERSION={WHEEL_VERSION}',
- '-DENABLE_WHEEL=ON']
+ f'-DPYTHON_INCLUDE_DIR={python_include_dir}',
+ '-DNGRAPH_PYTHON_BUILD_ENABLE=ON',
+ f'-DCMAKE_BUILD_TYPE={build_configuration_name}',
+ f'-DOPENVINO_EXTRA_MODULES={self.openvino_contrib_src_dir}/modules/nvidia_plugin',
+ '-DENABLE_WHEEL=ON',
+ f'-DWHEEL_VERSION={WHEEL_VERSION}']
self.announce("Configuring OpenVINO CMake Project", level=3)
run_command(configure_command,
cwd=self.openvino_build_dir,
@@ -272,7 +310,7 @@ def build_openvino(self):
def get_build_env(self):
build_env = os.environ.copy()
- build_env['BUILD_TYPE'] = self.build_configuration_name
+ build_env['BUILD_TYPE'] = build_configuration_name
build_env['BUILD_TARGETS'] = NVIDIA_PLUGIN_CMAKE_TARGET_NAME
build_env['OPENVINO_HOME'] = self.openvino_src_dir
build_env['OPENVINO_CONTRIB'] = self.openvino_contrib_src_dir
@@ -333,65 +371,103 @@ def locate_built_lib(self):
set_rpath(LIBS_RPATH, os.path.realpath(path))
-class InstallCMakeLib(install_lib):
+class InstallLib(install_lib):
def finalize_options(self):
- super().finalize_options()
+ install_lib.finalize_options(self)
+
self.git_exec = shutil.which("git")
self.force = None
self.set_undefined_options('install', ('force', 'force'))
+ print(f"self.force = {self.force}")
def run(self):
+ openvino_nvidia_gpu_library = f'{openvino_src_dir}/bin/intel64/{build_configuration_name}/lib/libopenvino_nvidia_gpu_plugin.{platform_specifics.get_lib_file_extension()}'
+ package_data.update({
+ '': [openvino_nvidia_gpu_library]
+ })
+
+ self.build()
+ self.install()
+
try:
- self.build()
- self.install()
- self.install_openvino_package_and_other_dependencies()
+ if self.force:
+ self.install_openvino_package()
+ self.install_python_dependencies()
self.register_nvidia_plugin()
self.test_nvidia_plugin()
- openvino_nvidia_gpu_library = f'{openvino_src_dir}/bin/intel64/Release/lib/libopenvino_nvidia_gpu_plugin.{platform_specifics.get_lib_file_extension()}'
- package_data.update({
- '': [openvino_nvidia_gpu_library]
- })
- finally:
+ except Exception as ex:
self.unregister_nvidia_plugin()
- def install_openvino_package_and_other_dependencies(self):
- if self.force:
- py_tag=tags.interpreter_name() + tags.interpreter_version()
- abi_tag=wheel.bdist_wheel.get_abi_tag()
- platform_tag=next(tags.platform_tags())
- git_commits=get_command_output([self.git_exec, 'rev-list', '--count', '--first-parent', 'HEAD'],
- cwd=openvino_src_dir, on_fail_msg='Failed to count OpenVINO commits').strip()
- openvino_wheel_name="-".join(["openvino", WHEEL_VERSION, git_commits, py_tag, abi_tag, platform_tag]) + ".whl"
- wheels_path = os.path.abspath(os.path.join(openvino_src_dir, "build/wheels", openvino_wheel_name))
- self.announce(f"Installing OpenVINO package with {wheels_path}", level=3)
- openvino_install_py = create_pip_command(wheels_path)
- run_command(openvino_install_py,
- on_fail_msg=f'Failed to install OpenVINO wheel package with {wheels_path}')
-
+ def install_openvino_package(self):
+ py_tag=tags.interpreter_name() + tags.interpreter_version()
+ abi_tag=wheel.bdist_wheel.get_abi_tag()
+ platform_tag=next(tags.platform_tags())
+ git_commits=get_command_output([self.git_exec, 'rev-list', '--count', '--first-parent', 'HEAD'],
+ cwd=openvino_src_dir,
+ on_fail_msg='Failed to count OpenVINO commits').strip()
+ openvino_wheel_name="-".join(["openvino", WHEEL_VERSION, git_commits, py_tag, abi_tag, platform_tag]) + ".whl"
+ wheels_path = os.path.abspath(os.path.join(openvino_src_dir, "build/wheels", openvino_wheel_name))
+ self.announce(f"Installing OpenVINO package with {wheels_path}", level=3)
+ openvino_install_py = create_pip_command(wheels_path)
+ run_command(openvino_install_py,
+ on_fail_msg=f'Failed to install OpenVINO wheel package with {wheels_path}')
+
+ def install_python_dependencies(self):
path_to_requirements_txt = os.path.join(os.path.abspath(os.path.dirname(__file__)), "requirements.txt")
requirements_py = create_pip_command('-r', path_to_requirements_txt)
run_command(requirements_py,
on_fail_msg=f'Failed to install dependencies from {path_to_requirements_txt}')
+ def check_plugins_xml_if_exists(self):
+ openvino_package_libs_dir = self.get_openvino_package_dir()
+ xml_file = os.path.join(openvino_package_libs_dir, "plugins.xml")
+ if not os.path.exists(xml_file):
+ plugins_xml_src = dedent('''\
+
+
+
+
+ ''')
+ tree = ET.fromstring(plugins_xml_src)
+ with open(xml_file, "w") as f:
+ f.write(ET.tostring(tree).decode('utf8'))
+
+ def update_plugins_xml(self, xml_file, openvino_nvidia_gpu_library):
+ if not os.path.exists(xml_file):
+ plugins_xml_src = dedent('''\
+
+
+
+
+ ''')
+ tree = ET.fromstring(plugins_xml_src)
+ else:
+ tree = ET.parse(xml_file).getroot()
+
+ plugins = tree.find("plugins")
+ if all(plugin.get('name') != 'NVIDIA' for plugin in plugins.iter('plugin')):
+ plugins.append(Element('plugin', {'name': 'NVIDIA', 'location': openvino_nvidia_gpu_library}))
+ with open(xml_file, "w") as f:
+ f.write(ET.tostring(tree).decode('utf8'))
+
def get_openvino_package_dir(self):
import openvino
openvino_package_dir = os.path.dirname(os.path.abspath(openvino.__file__))
openvino_package_libs_dir = os.path.join(openvino_package_dir, "libs")
return openvino_package_libs_dir
+ def get_openvino_nvidia_lib_path(self):
+ import openvino_nvidia
+ openvino_nvidia_package_dir = os.path.dirname(os.path.abspath(openvino_nvidia.__file__))
+ openvino_nvidia_gpu_library = f'{openvino_nvidia_package_dir}/libopenvino_nvidia_gpu_plugin.{platform_specifics.get_lib_file_extension()}'
+ return openvino_nvidia_gpu_library
+
def register_nvidia_plugin(self):
+ self.check_plugins_xml_if_exists()
openvino_package_libs_dir = self.get_openvino_package_dir()
- self.copy_tree(self.build_dir, openvino_package_libs_dir)
- openvino_nvidia_gpu_library = os.path.join(openvino_package_libs_dir,
- f"libopenvino_nvidia_gpu_plugin.{platform_specifics.get_lib_file_extension()}")
-
+ openvino_nvidia_gpu_library = self.get_openvino_nvidia_lib_path()
xml_file = os.path.join(openvino_package_libs_dir, "plugins.xml")
- tree = ET.parse(xml_file).getroot()
- plugins = tree.find("plugins")
- if all(plugin.get('name') != 'NVIDIA' for plugin in plugins.iter('plugin')):
- plugins.append(Element('plugin', {'name': 'NVIDIA', 'location': openvino_nvidia_gpu_library}))
- with open(xml_file, "w") as f:
- f.write(ET.tostring(tree).decode('utf8'))
+ self.update_plugins_xml(xml_file, openvino_nvidia_gpu_library)
def unregister_nvidia_plugin(self):
openvino_package_libs_dir = self.get_openvino_package_dir()
@@ -407,7 +483,7 @@ def unregister_nvidia_plugin(self):
break
def test_nvidia_plugin(self):
- from openvino.runtime import Core
+ import openvino as ov
test_model_convert_fp32 = """
@@ -439,7 +515,7 @@ def test_nvidia_plugin(self):
""".encode('ascii')
- core = Core()
+ core = ov.Core()
model = core.read_model(model=test_model_convert_fp32)
try:
core.compile_model(model=model, device_name="NVIDIA")
@@ -453,8 +529,6 @@ def test_nvidia_plugin(self):
f'Possible ABI version mismatch. {recommendations_msg}') from e
-package_data: typing.Dict[str, list] = {}
-
setup(
version=config('WHEEL_VERSION', WHEEL_VERSION),
author_email=config('WHEEL_AUTHOR_EMAIL', 'openvino_pushbot@intel.com'),
@@ -470,12 +544,12 @@ def test_nvidia_plugin(self):
libraries=[(PACKAGE_NAME, {'sources': []})],
packages=["openvino_nvidia"],
package_dir={
- "openvino_nvidia": f"{os.path.abspath(os.path.dirname(__file__))}/openvino_nvidia",
+ "openvino_nvidia": f"{os.path.abspath(os.path.dirname(__file__))}/packages/openvino_nvidia",
},
package_data=package_data,
cmdclass={
'build_clib': BuildCMakeLib,
- 'install_lib': InstallCMakeLib,
+ 'install_lib': InstallLib,
},
zip_safe=False,
)