[PyOV] Drop Python 3.6 support (#12280)
* Drop Python 3.6 * Test dropping Python to 3.6 in py_checks.yml * Allow Python 3.6 for open source * Add docs on upgrading Python
This commit is contained in:
committed by
GitHub
parent
2e6eaa6c7e
commit
d5a274b0e4
@@ -15,12 +15,12 @@ Supported Python* versions:
|
||||
|
||||
| Operating System | Supported Python\* versions: |
|
||||
|:----- | :----- |
|
||||
| Ubuntu\* 18.04 | 3.6, 3.7 |
|
||||
| Ubuntu\* 20.04 | 3.6, 3.7, 3.8 |
|
||||
| Windows\* 10 | 3.6, 3.7, 3.8 |
|
||||
| CentOS\* 7.3 | 3.6, 3.7 |
|
||||
| macOS\* 10.x | 3.6, 3.7 |
|
||||
| Raspbian\* 9 | 3.6, 3.7 |
|
||||
| Ubuntu\* 18.04 | 3.7 |
|
||||
| Ubuntu\* 20.04 | 3.7, 3.8 |
|
||||
| Windows\* 10 | 3.7, 3.8 |
|
||||
| CentOS\* 7.3 | 3.7 |
|
||||
| macOS\* 10.x | 3.7 |
|
||||
| Raspbian\* 9 | 3.7 |
|
||||
|
||||
|
||||
## Set Up the Environment
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*To be added...*
|
||||
|
||||
##### Enviroment
|
||||
In case the Python version you have is not supported by OpenVINO, you can refer to [openvino/src/bindings/python/docs/python_version_upgrade.md](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/python/docs/python_version_upgrade.md) for instructions on how to download and build a newer, supported Python version.
|
||||
<!-- TODO: Link to enviroment setup -->
|
||||
*To be added...*
|
||||
|
||||
|
||||
37
src/bindings/python/docs/python_version_upgrade.md
Normal file
37
src/bindings/python/docs/python_version_upgrade.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Python version upgrade
|
||||
|
||||
#### Notes
|
||||
Upgrade described in this documentation file can be useful when using a system such as Ubuntu18, which default Python is no longer supported (in this case Python 3.6). The recommended action is to use a newer system instead of upgrading Python.
|
||||
|
||||
*Warning: You make all changes at your own risk.*
|
||||
|
||||
## Building and installing Python for Linux
|
||||
|
||||
Download Python from Python releases page and extract it:
|
||||
https://www.python.org/downloads/release
|
||||
```bash
|
||||
curl -O https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
|
||||
tar -xf Python-3.8.13.tgz
|
||||
```
|
||||
|
||||
Prepare the build with the `.configure` tool, ensuring that `pip` will be installed:
|
||||
```bash
|
||||
cd Python-3.8.13
|
||||
./configure --with-ensurepip=install
|
||||
```
|
||||
|
||||
Build Python with number of jobs suitable for your machine:
|
||||
```bash
|
||||
make -j 8
|
||||
```
|
||||
|
||||
Install your new Python version, making sure not to overwrite system Python by using `altinstall` target:
|
||||
```bash
|
||||
sudo make altinstall
|
||||
```
|
||||
|
||||
Verify your installation:
|
||||
```bash
|
||||
python3.8 --version
|
||||
> Python 3.8.13
|
||||
```
|
||||
@@ -78,7 +78,7 @@ show_column_numbers = True
|
||||
show_error_context = True
|
||||
show_absolute_path = True
|
||||
pretty = True
|
||||
follow_imports=normal
|
||||
follow_imports = normal
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
check_untyped_defs = True
|
||||
|
||||
@@ -1557,7 +1557,6 @@ def matmul(
|
||||
:param transpose_b: should the second matrix be transposed
|
||||
:return: MatMul operation node
|
||||
"""
|
||||
print("transpose_a", transpose_a, "transpose_b", transpose_b)
|
||||
return _get_node_factory_opset1().create(
|
||||
"MatMul", as_nodes(data_a, data_b), {"transpose_a": transpose_a, "transpose_b": transpose_b}
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
- [CMake\*](https://cmake.org/download/) 3.9 or later
|
||||
- Microsoft\* Visual Studio 2015 or later on Windows\*
|
||||
- gcc 4.8 or later on Linux
|
||||
- Python 2.7 or higher on Linux\*
|
||||
- Python 3.6 or higher on Windows\*
|
||||
- Python 3.7 or higher on Linux\*
|
||||
- Python 3.7 or higher on Windows\*
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -21,9 +21,9 @@ You need to run Inference Engine build with the following flags:
|
||||
cd <INSTALL_DIR>/openvino
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=`which python3.6` \
|
||||
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.6 ..
|
||||
cmake -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=`which python3.7` \
|
||||
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.7 ..
|
||||
make -j16
|
||||
```
|
||||
|
||||
@@ -65,7 +65,7 @@ sudo apt install patchelf
|
||||
## Running sample
|
||||
|
||||
Before running the Python samples:
|
||||
- add the folder with built `openvino` Python module (located at `bin/intel64/Release/lib/python_api/python3.6` for Linux) to the PYTHONPATH environment variable.
|
||||
- add the folder with built `openvino` Python module (located at `bin/intel64/Release/lib/python_api/python3.7` for Linux) to the PYTHONPATH environment variable.
|
||||
- add the folder with Inference Engine libraries to LD_LIBRARY_PATH variable on Linux (or PATH on Windows).
|
||||
|
||||
Example of command line to run classification sample:
|
||||
|
||||
@@ -21,4 +21,4 @@ disable_error_code = attr-defined
|
||||
show_column_numbers = True
|
||||
show_error_context = True
|
||||
show_absolute_path = True
|
||||
pretty = True
|
||||
pretty = True
|
||||
|
||||
@@ -41,11 +41,11 @@ def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
|
||||
pad = (-data_size) % num_values_fitting_into_uint8
|
||||
|
||||
flattened = casted_to_regular_type.flatten()
|
||||
padded = np.concatenate((flattened, np.zeros([pad], dtype=minimum_regular_dtype)))
|
||||
padded = np.concatenate((flattened, np.zeros([pad], dtype=minimum_regular_dtype))) # type: ignore
|
||||
assert padded.size % num_values_fitting_into_uint8 == 0
|
||||
|
||||
bit_order_little = (padded[:, None] & (1 << np.arange(num_bits)) > 0).astype(minimum_regular_dtype)
|
||||
bit_order_big = np.flip(bit_order_little, axis=1)
|
||||
bit_order_big = np.flip(bit_order_little, axis=1) # type: ignore
|
||||
bit_order_big_flattened = bit_order_big.flatten()
|
||||
|
||||
return np.packbits(bit_order_big_flattened)
|
||||
@@ -74,7 +74,7 @@ def unpack_data(array: np.ndarray, type: Type, shape: Union[list, Shape]) -> np.
|
||||
else:
|
||||
unpacked = unpacked.reshape(-1, type.bitwidth)
|
||||
padding_shape = (unpacked.shape[0], 8 - type.bitwidth)
|
||||
padding = np.ndarray(padding_shape, np.uint8)
|
||||
padding = np.ndarray(padding_shape, np.uint8) # type: np.ndarray
|
||||
if type == Type.i4:
|
||||
for axis, bits in enumerate(unpacked):
|
||||
if bits[0] == 1:
|
||||
@@ -83,7 +83,7 @@ def unpack_data(array: np.ndarray, type: Type, shape: Union[list, Shape]) -> np.
|
||||
padding[axis] = np.zeros((padding_shape[1],), np.uint8)
|
||||
else:
|
||||
padding = np.zeros(padding_shape, np.uint8)
|
||||
padded = np.concatenate((padding, unpacked), 1)
|
||||
padded = np.concatenate((padding, unpacked), 1) # type: ignore
|
||||
packed = np.packbits(padded, 1)
|
||||
if type == Type.i4:
|
||||
return np.resize(packed, shape).astype(dtype=np.int8)
|
||||
|
||||
@@ -15,13 +15,11 @@ from openvino.pyopenvino import InferRequest as InferRequestBase
|
||||
from openvino.pyopenvino import AsyncInferQueue as AsyncInferQueueBase
|
||||
from openvino.pyopenvino import ConstOutput
|
||||
from openvino.pyopenvino import Tensor
|
||||
from openvino.pyopenvino import Type
|
||||
from openvino.pyopenvino import Shape
|
||||
|
||||
|
||||
def tensor_from_file(path: str) -> Tensor:
|
||||
"""Create Tensor from file. Data will be read with dtype of unit8."""
|
||||
return Tensor(np.fromfile(path, dtype=np.uint8))
|
||||
return Tensor(np.fromfile(path, dtype=np.uint8)) # type: ignore
|
||||
|
||||
|
||||
def set_scalar_tensor(request: InferRequestBase, tensor: Tensor, key: Union[str, int, ConstOutput] = None) -> None:
|
||||
|
||||
@@ -411,7 +411,7 @@ def compare_models(current, expected): # noqa: C901 the function is too complex
|
||||
msg += f"expected: {expected_ops[i].get_output_element_type(idx)}. "
|
||||
|
||||
if not result:
|
||||
print(msg)
|
||||
print(msg) # noqa: T201
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_load_by_unknown_framework():
|
||||
try:
|
||||
fem.load_by_framework("UnknownFramework")
|
||||
except InitializationFailure as exc:
|
||||
print(exc)
|
||||
print(exc) # noqa: T201
|
||||
else:
|
||||
raise AssertionError("Unexpected exception.")
|
||||
|
||||
|
||||
@@ -82,4 +82,4 @@ def all_arrays_equal(first_list, second_list):
|
||||
:param second_list: another iterable containing numpy ndarray objects
|
||||
:return: True if all ndarrays are equal, otherwise False
|
||||
"""
|
||||
return all(map(lambda pair: np.array_equal(*pair), zip(first_list, second_list)))
|
||||
return all(map(lambda pair: np.array_equal(*pair), zip(first_list, second_list))) # noqa: C417
|
||||
|
||||
@@ -29,7 +29,7 @@ def test_compare_models():
|
||||
status, _ = compare_models(model, model)
|
||||
assert status
|
||||
except RuntimeError:
|
||||
print("openvino.test_utils.compare_models is not available")
|
||||
print("openvino.test_utils.compare_models is not available") # noqa: T201
|
||||
|
||||
|
||||
def generate_image(shape: Tuple = (1, 3, 32, 32), dtype: Union[str, np.dtype] = "float32") -> np.array:
|
||||
|
||||
@@ -358,7 +358,7 @@ def remove_rpath(file_path):
|
||||
|
||||
def set_rpath(rpath, executable):
|
||||
"""Setting rpath for linux and macOS libraries."""
|
||||
print(f"Setting rpath {rpath} for {executable}") # noqa: T001
|
||||
print(f"Setting rpath {rpath} for {executable}") # noqa: T001, T201
|
||||
cmd = []
|
||||
rpath_tool = ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user