Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/nvidia_plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist/

report_api.xml
report_op.xml
wheel/packages/openvino_nvidia/lib/
54 changes: 54 additions & 0 deletions modules/nvidia_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,60 @@ During compilation of the openvino_nvidia_gpu_plugin, user could specify the fol
nvidia-smi --query-gpu=compute_cap --format=csv
```

## Python package

Python package could be built using `wheel/setup.py` file provided in nvidia_plugin folder.

### Prerequisites
Run the following commands as prerequisites to `setup.py`:
```bash
export OPENVINO_HOME=<OPENVINO_HOME_DIR> # If not provided, setup.py will download openvino automatically
python3 -m pip install wheel
```

### Building the package
To build it, use simply the following command:
```bash
python3 ./wheel/setup.py bdist_wheel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling bdist_wheel manually has been deprecated for a while, going as far as an official Python blog saying that they mustn't be run anymore. The recommended replacement is python -m build which requires build dependency. Could you please check if running it is compatible and works well? We shouldn't introduce functionality based on outdated, possibly broken command.

Same goes for setup.py install below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality could be done iteratively.
In my current python environment python -m build failed due to missed dependencies (probably because I have custom build for python)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of introducing a functionality which we know may be broken/is not only not recommended, but soft-forbidden by Python docs. These things tend to stick around as a "TODO" and later cause issues at the most inconvenient time.

I haven't maintained NVIDIA plugin before so IMO my opinion can be overridden if you wish to do so (cc @p-durandin). If we decide to merge it as-is at the very least let's create a ticket to update the build method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@p-wysocki thanks, lets merge with creating github issue

```

### Installing the package
To install:
```bash
python3 ./wheel/setup.py install
```

### Usage
Now you can use `openvino-nvidia` package, here is example:
```python
import openvino_nvidia
import openvino as ov

core = ov.Core()
model = core.read_model(model=...)
core.compile_model(model=model, device_name="NVIDIA")
```
During the import of package `openvino_nvidia` it tries to register itself in `openvino` package.
Registration happens in "lightweight" manner, it means if "NVIDIA" plugin already registered than it does nothing.
If you want forcely overwrite a path to plugin library you can do it by importing from `openvino_nvidia` package attribute `force_install`:
```python
from openvino_nvidia import force_install # will overwrite a path to plugin library
import openvino as ov

core = ov.Core()
model = core.read_model(model=...)
core.compile_model(model=model, device_name="NVIDIA")
```
For symmetry there is also `install` attribute:
```python
from openvino_nvidia import install # will register plugin if it does not yet
import openvino as ov

core = ov.Core()
model = core.read_model(model=...)
core.compile_model(model=model, device_name="NVIDIA")
```

## Supported Layers and Limitations
The plugin supports IRv10 and higher. The list of supported layers and its limitations are defined in [cuda_opset.md](docs/cuda_opset.md).

Expand Down
14 changes: 11 additions & 3 deletions modules/nvidia_plugin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ fi

BUILD_JOBS=${BUILD_JOBS:-$(nproc)}
BUILD_TYPE=${BUILD_TYPE:-Release}
BUILD_TARGETS=${BUILD_TARGETS:-"ov_nvidia_func_tests ov_nvidia_unit_tests openvino_nvidia_gpu_plugin benchmark_app"}
WHEEL_VERSION=${WHEEL_VERSION:-"2022.3.0"}

ENABLE_WHEEL=${ENABLE_WHEEL:-"OFF"}
WHEEL_VERSION=${WHEEL_VERSION:-"2025.3.0"}
WHEEL_TARGET=""
if [ "$ENABLE_WHEEL" = "ON" ]; then
WHEEL_TARGET="ie_wheel"
fi

BUILD_TARGETS=${BUILD_TARGETS:-"${WHEEL_TARGET} ov_nvidia_func_tests ov_nvidia_unit_tests openvino_nvidia_gpu_plugin benchmark_app"}
ENABLE_TESTS=${ENABLE_TESTS:-"ON"}
ENABLE_FUNCTIONAL_TESTS=${ENABLE_FUNCTIONAL_TESTS:-"OFF"}
ENABLE_FUNCTIONAL_TESTS=${ENABLE_FUNCTIONAL_TESTS:-"ON"}

[[ -n "${OPENVINO_HOME}" ]] || { echo "OPENVINO_HOME environment variable is expected"; exit 1; }
[[ -n "${OPENVINO_CONTRIB}" ]] || { echo "OPENVINO_CONTRIB environment variable is expected"; exit 1; }
Expand Down Expand Up @@ -43,6 +50,7 @@ cmake "${OPENVINO_HOME}" \
-DENABLE_PLUGINS_XML=ON \
-DENABLE_TESTS="${ENABLE_TESTS}" \
-DENABLE_FUNCTIONAL_TESTS="${ENABLE_FUNCTIONAL_TESTS}" \
-DENABLE_WHEEL="${ENABLE_WHEEL}" \
-DBUILD_arm_plugin=OFF \
-DBUILD_java_api=OFF \
-DBUILD_llama_cpp_plugin=OFF \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,44 @@ def _get_lib_file_extension() -> str:
return "dylib"


def _register_nvidia_plugin():
def _register_nvidia_plugin(force=False):
import openvino
openvino_package_dir = os.path.dirname(os.path.abspath(openvino.__file__))
openvino_package_libs_dir = os.path.join(openvino_package_dir, "libs")
openvino_nvidia_gpu_package_dir = os.path.dirname(os.path.abspath(__file__))
openvino_nvidia_gpu_library = os.path.join(openvino_nvidia_gpu_package_dir, f"../libopenvino_nvidia_gpu_plugin.{_get_lib_file_extension()}")
openvino_nvidia_gpu_library = os.path.join(openvino_nvidia_gpu_package_dir, f"./lib/libopenvino_nvidia_gpu_plugin.{_get_lib_file_extension()}")

xml_file = os.path.join(openvino_package_libs_dir, "plugins.xml")
xml_file_updated = False
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}))

if force:
for plugin in plugins:
if plugin.tag == "plugin" and plugin.get("name") == "NVIDIA":
plugins.remove(plugin)
plugins.append(Element('plugin', {'name': 'NVIDIA', 'location': openvino_nvidia_gpu_library}))
xml_file_updated = True
else:
if all(plugin.get('name') != 'NVIDIA' for plugin in plugins.iter('plugin')):
plugins.append(Element('plugin', {'name': 'NVIDIA', 'location': openvino_nvidia_gpu_library}))
xml_file_updated = True

if xml_file_updated:
with open(xml_file, "w") as f:
f.write(ET.tostring(tree).decode('utf8'))


def __getattr__(name):
if name == "install":
_register_nvidia_plugin()
elif name == "force_install":
_register_nvidia_plugin(True)
else:
raise AttributeError(f"module {__name__} has no attribute {name}")


_register_nvidia_plugin()

__version__ = "2024.1.0"

__version__ = "2025.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should be setting this dynamically based on openvino version, or at least set it to an upcoming 2025.4.0 if we plan to release it? I'm not sure how it should be done, @artanokhov do you know?

One way or another, if we'd like to set this dynamically, this is a topic for a different PR.

Copy link
Contributor Author

@redradist redradist Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should be setting this dynamically based on openvino version, or at least set it to an upcoming 2025.4.0 if we plan to release it?

@p-wysocki Have not idea, I am not the official maintainer of NVIDIA plugin, I am the former developer of it and I know pretty good its architecture.
In future I expect Intel will publish packages for openvino-nvidia, but for this proper CI should be configured

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==2024.1.0
openvino==2025.3.0
Loading
Loading