Skip to content

Commit 763886a

Browse files
authored
CPU-only installation mode for OTX (#4972)
Add 'cpu' extra dependency to install OTX in CPU-only mode; CPU is the most lightweight installation option as it doesn't include GPU/XPU drivers. It can be useful for platforms that don't have a GPU (embedded devices, laptops, CI workers, ...)
1 parent a4db799 commit 763886a

File tree

3 files changed

+79
-114
lines changed

3 files changed

+79
-114
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,35 @@ If you want to make changes to the library, then a local installation is recomme
7373

7474
<details>
7575
<summary>Install from PyPI</summary>
76-
Installing the library with uv tool is the easiest way to get started with otx.
76+
Installing the library with pip or uv is the easiest way to get started with otx.
7777

7878
```bash
79-
uv pip install otx[cuda]
80-
```
79+
# Without GPU support (CPU only)
80+
pip install otx[cpu]
8181

82-
For Intel GPUs users:
82+
# With Intel GPU support (XPU)
83+
pip install otx[xpu]
8384

84-
```bash
85-
uv pip install otx[xpu]
85+
# With NVIDIA GPU support (CUDA)
86+
pip install otx[cuda]
8687
```
8788

8889
</details>
8990

9091
<details>
9192
<summary>Install from source</summary>
92-
To install from source, you need to clone the repository and install the library using uv pip via editable mode.
93+
To install from source, you need to clone the repository and install the library with pip or uv.
94+
It is recommended to use a virtual environment to avoid conflicts with other packages.
9395

9496
```bash
95-
# Create a new virtual environment using uv (Python 3.11)
96-
uv venv .otx --python 3.11
97-
source .otx/bin/activate
98-
9997
# Clone the repository
10098
git clone https://github.com/open-edge-platform/training_extensions.git
10199
cd training_extensions
102100

103-
# Install in editable mode
104-
uv pip install -e .[cuda]
105-
# For Intel GPUs users
106-
uv pip install -e .[xpu]
101+
# Install (optional: pass the '-e' flag for editable mode
102+
# If you have an Intel GPU, use 'xpu' to enable support.
103+
# If you have an NVIDIA GPU, use 'cuda' to enable support.
104+
pip install -e .[cpu]
107105
```
108106

109107
</details>

library/docs/source/guide/get_started/installation.rst

Lines changed: 46 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,139 +16,95 @@ The current version of OpenVINO™ Training Extensions was tested in the followi
1616
To enable efficient execution of multiple models, we increase the ONEDNN_PRIMITIVE_CACHE_CAPACITY environment variable from its default value to 10000.
1717
For more information, refer to the `Primitive cache <https://www.intel.com/content/www/us/en/docs/onednn/developer-guide-reference/2024-1/primitive-cache-002.html>`_.
1818

19-
***************
20-
Installing ``uv``
21-
***************
19+
*****************
20+
Install from pypi
21+
*****************
2222

23-
To use OpenVINO™ Training Extensions with ``uv``, you first need to install the ``uv`` tool.
23+
The easiest way to install OpenVINO™ Training Extensions is via PyPI (`otx <https://pypi.org/project/otx>`_ package).
2424

25-
You can install it in one of the following ways:
25+
Select the extra dependencies according to your hardware:
2626

2727
.. tab-set::
2828

29-
.. tab-item:: Recommended (Standalone Binary)
30-
31-
.. code-block:: shell
32-
33-
curl -LsSf https://astral.sh/uv/install.sh | sh
34-
35-
This method installs ``uv`` globally as a fast and portable binary.
36-
After installation, make sure ``uv`` is available in your ``PATH``.
37-
38-
.. tab-item:: Via pip (Python-based)
39-
40-
.. code-block:: shell
41-
42-
pip install uv
43-
44-
This installs ``uv`` inside the currently active Python environment.
45-
46-
.. tab-item:: Verify Installation
47-
48-
After installation, confirm it works:
29+
.. tab-item:: CPU only
4930

5031
.. code-block:: shell
5132
52-
uv --version
53-
33+
pip install otx[cpu]
5434
55-
**********************************************************
56-
Install OpenVINO™ Training Extensions for users (CUDA/CPU)
57-
**********************************************************
58-
59-
1. Install OpenVINO™ Training Extensions package:
60-
61-
* A local source in development mode
62-
63-
.. tab-set::
64-
65-
.. tab-item:: PyPI
35+
.. tab-item:: Intel GPU (XPU)
6636

6737
.. code-block:: shell
6838
69-
# Create a virtual environment using uv
70-
uv venv .otx --python 3.12 # or 3.11
71-
source .otx/bin/activate
72-
73-
# Install from PyPI
74-
uv pip install otx[cuda]
39+
pip install otx[xpu]
7540
76-
.. tab-item:: Source
41+
.. tab-item:: Nvidia GPU (CUDA)
7742

7843
.. code-block:: shell
7944
80-
# Clone the training_extensions repository:
81-
git clone https://github.com/open-edge-platform/training_extensions.git
82-
cd training_extensions
83-
84-
# Create a virtual environment with uv
85-
uv venv .otx --python 3.12 # or 3.11
86-
source .otx/bin/activate
45+
pip install otx[cuda]
8746
88-
# Install the package in editable mode with base dependencies
89-
uv pip install -e .[cuda]
47+
.. note::
9048

91-
# Install OTX in development mode
92-
uv pip install -e .[dev,cuda]
49+
It is always recommended to use a virtual environment to avoid conflicts with other packages.
9350

94-
2. Once the package is installed in the virtual environment, you can use the full
95-
OpenVINO™ Training Extensions command line functionality.
51+
After the installation, you can verify it works with:
9652

9753
.. code-block:: shell
9854
9955
otx --help
10056
101-
*************************************************************
102-
Install OpenVINO™ Training Extensions for users (Intel GPUs)
103-
*************************************************************
104-
105-
1. Install OpenVINO™ Training Extensions from source to use Intel XPU functionality:
10657
107-
.. code-block:: shell
58+
*******************
59+
Install from source
60+
*******************
10861

109-
git clone https://github.com/open-edge-platform/training_extensions.git
110-
cd training_extensions
62+
If you want to install OpenVINO™ Training Extensions from source, you have to first clone the repository,
63+
then install the package.
11164

112-
uv venv .otx --python 3.12 # or 3.11
113-
source .otx/bin/activate
65+
.. tab-set::
11466

115-
uv pip install -e .[xpu]
67+
.. tab-item:: CPU only
11668

117-
.. note::
69+
.. code-block:: shell
11870
119-
Please refer to the `PyTorch XPU installation guide <https://pytorch.org/docs/stable/notes/get_start_xpu.html>`_
120-
to install prerequisites and resolve any potential issues.
71+
git clone https://github.com/open-edge-platform/training_extensions.git
72+
cd training_extensions/library
73+
pip install .[cpu]
12174
122-
2. Once installed, use the command-line interface:
75+
.. tab-item:: Intel GPU (XPU)
12376

124-
.. code-block:: shell
77+
.. code-block:: shell
12578
126-
otx --help
79+
git clone https://github.com/open-edge-platform/training_extensions.git
80+
cd training_extensions/library
81+
pip install .[xpu]
12782
128-
****************************************************
129-
Install OpenVINO™ Training Extensions for developers
130-
****************************************************
83+
.. tab-item:: Nvidia GPU (CUDA)
13184

132-
1. Install ``tox`` with the ``tox-uv`` plugin using uv's tool system:
85+
.. code-block:: shell
13386
134-
.. code-block:: shell
87+
git clone https://github.com/open-edge-platform/training_extensions.git
88+
cd training_extensions/library
89+
pip install .[cuda]
13590
136-
uv tool install tox --with tox-uv
13791
138-
2. Create a development environment using ``tox``:
92+
**************
93+
For developers
94+
**************
13995

140-
.. code-block:: shell
96+
For developers, it is recommended to use `uv` to automatically manage virtual environments and dependencies.
14197

142-
# Replace '312' with '311' if using Python 3.11
143-
tox devenv venv/otx -e unit-test-py312
144-
source venv/otx/bin/activate
98+
.. code-block::
14599
146-
Now you're ready to develop, test, and make changes — all reflected live in the editable install.
100+
# Clone the repo
101+
git clone https://github.com/open-edge-platform/training_extensions.git
102+
cd training_extensions/library
147103
148-
.. note::
104+
# Create a virtual environment with uv and sync dependencies
105+
uv sync --extra cpu # or 'xpu' or 'cuda', depending on your hardware
149106
150-
By installing ``tox`` with ``uv tool``, you ensure it runs in a reproducible and isolated environment,
151-
with ``uv`` used internally to manage dependencies for each test environment.
107+
If you plan to edit the documentation, also install the `docs` extra.
152108

153109

154110
*****************************************************

library/pyproject.toml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SETUP CONFIGURATION. #
33
[build-system]
44
requires = [
5-
"setuptools>=61",
5+
"setuptools>=77.0.0",
66
"wheel",
77
]
88
build-backend = "setuptools.build_meta"
@@ -13,13 +13,12 @@ dynamic = ["version"]
1313
description = "OpenVINO™ Training Extensions: Train, Evaluate, Optimize, Deploy Computer Vision Models via OpenVINO™"
1414
readme = "README.md"
1515
requires-python = ">=3.10"
16-
license = {file = "LICENSE"}
16+
license = "Apache-2.0"
1717
authors = [
1818
{ name = "OpenVINO™ Training Extensions Contributors" },
1919
]
2020
classifiers = [
2121
"Development Status :: 5 - Production/Stable",
22-
"License :: OSI Approved :: Apache Software License",
2322
"Programming Language :: Cython",
2423
"Programming Language :: Python :: 3",
2524
"Programming Language :: Python :: 3.10",
@@ -37,22 +36,21 @@ dependencies = [
3736
"docstring_parser==0.16", # CLI help-formatter
3837
"rich_argparse==1.7.0", # CLI help-formatter
3938
"einops==0.8.1",
40-
"decord==0.6.0",
4139
"typeguard>=4.3,<4.5",
4240
"setuptools==78.1.1",
4341
"lightning==2.4.0",
4442
"torchmetrics==1.6.0",
4543
"pytorchcv==0.0.67",
4644
"timm==1.0.3",
4745
"openvino==2025.2",
48-
"openvino-model-api==0.3.0.2",
49-
"onnx==1.17.0",
46+
"openvino-model-api==0.3.0.4",
47+
"onnx==1.19.1",
5048
"onnxconverter-common==1.16.0",
5149
"onnxscript==0.5.3",
5250
"nncf==2.17.0",
5351
"anomalib[core]==1.1.3",
5452
"imgaug==0.4.0", # for anomalib
55-
"numpy>2.0",
53+
"numpy>=2.0",
5654
"tensorboardx==2.6.4"
5755
]
5856

@@ -71,8 +69,13 @@ dev = [
7169
"onnxruntime==1.21.1",
7270
]
7371

74-
cuda = ["torch==2.8.0",
75-
"torchvision==0.23.0"
72+
cpu = [
73+
"torch==2.8.0",
74+
"torchvision==0.23.0"
75+
]
76+
cuda = [
77+
"torch==2.8.0",
78+
"torchvision==0.23.0"
7679
]
7780
xpu = [
7881
"torch==2.8.0+xpu",
@@ -118,20 +121,23 @@ Repository = "https://github.com/open-edge-platform/training_extensions/"
118121
[tool.uv]
119122
conflicts = [
120123
[
124+
{ extra = "cpu" },
121125
{ extra = "xpu" },
122126
{ extra = "cuda" },
123127
],
124128
]
125129

126130
[tool.uv.sources]
127131
torch = [
132+
{ index = "torch-cpu", extra = "cpu"},
128133
{ index = "torch-xpu", extra = "xpu"},
129134
{ index = "torch-cuda", extra = "cuda"},
130135
]
131136
pytorch-triton-xpu = [
132137
{ index = "torch-xpu", extra = "xpu"},
133138
]
134139
torchvision = [
140+
{ index = "torch-cpu", extra = "cpu"},
135141
{ index = "torch-xpu", extra = "xpu"},
136142
{ index = "torch-cuda", extra = "cuda"},
137143
]
@@ -140,6 +146,11 @@ torchvision = [
140146
# For details: https://github.com/aleju/imgaug/issues/859
141147
imgaug = { git = "https://github.com/imaug/imaug/", rev = "a7ca1b04d44700d075a23f14a97f86285ba3b33f" }
142148

149+
[[tool.uv.index]]
150+
name = "torch-cpu"
151+
url = "https://download.pytorch.org/whl/cpu"
152+
explicit = true
153+
143154
[[tool.uv.index]]
144155
name = "torch-cuda"
145156
url = "https://download.pytorch.org/whl/cu128"

0 commit comments

Comments
 (0)