Skip to content

Commit

Permalink
Update setup.py script to make it buildable again
Browse files Browse the repository at this point in the history
  • Loading branch information
lohika-denis-kotov committed Oct 24, 2023
1 parent f691175 commit abcf9d5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
6 changes: 3 additions & 3 deletions modules/nvidia_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=2023.1.0 https://github.com/openvinotoolkit/openvino_contrib.git
```
2. Go to plugin directory:
```bash
Expand All @@ -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 _2023.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`
Expand Down Expand Up @@ -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=2023.1.0 https://github.com/openvinotoolkit/openvino_contrib.git
```
2. Go to plugin directory:
```bash
Expand Down
2 changes: 1 addition & 1 deletion modules/nvidia_plugin/wheel/openvino_nvidia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def _register_nvidia_plugin():

_register_nvidia_plugin()

__version__ = "2022.3.0"
__version__ = "2023.1.0"
2 changes: 1 addition & 1 deletion modules/nvidia_plugin/wheel/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
openvino==2022.3.0
openvino==2023.1.0
47 changes: 41 additions & 6 deletions modules/nvidia_plugin/wheel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import errno
import multiprocessing
import typing
import sysconfig
import defusedxml.ElementTree as ET
from defusedxml import defuse_stdlib

Expand All @@ -39,7 +40,7 @@

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', "2023.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'
Expand Down Expand Up @@ -147,6 +148,7 @@ def create_pip_command(*options):

def run_command(command, cwd: str = None, on_fail_msg: str = '', env=None):
try:
print(f"run_command: {' '.join(command)}")
subprocess.check_call(command, cwd=cwd, env=env) # nosec - disable B603:subprocess_without_shell_equals_true check
except subprocess.CalledProcessError as e:
raise RuntimeError(on_fail_msg) from e
Expand Down Expand Up @@ -226,15 +228,23 @@ 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()
self.build_nvidia_plugin()
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)
Expand All @@ -246,16 +256,41 @@ 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. Ensure you have all build dependencies '
'installed, by running '
f'{os.path.join(self.openvino_src_dir, OPENVINO_INSTALL_BUILD_DEPS_SCRIPT)} '
'script with admin rights.')

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}',
'-DVERBOSE_BUILD=ON',
'-DENABLE_NVIDIA=ON',
'-DENABLE_PYTHON=ON',
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={self.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,
Expand Down

0 comments on commit abcf9d5

Please sign in to comment.