mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 01:13:05 +00:00
openvino: 2021.2 -> 2022.3.0
Update and fix the python bindings. https://github.com/openvinotoolkit/openvino/releases/tag/2021.3 https://github.com/openvinotoolkit/openvino/releases/tag/2020.3.2 https://github.com/openvinotoolkit/openvino/releases/tag/2021.4 https://github.com/openvinotoolkit/openvino/releases/tag/2021.4.2 https://github.com/openvinotoolkit/openvino/releases/tag/2021.4.2 https://github.com/openvinotoolkit/openvino/releases/tag/2022.1.0 https://github.com/openvinotoolkit/openvino/releases/tag/2022.1.1 https://github.com/openvinotoolkit/openvino/releases/tag/2022.2.0 https://github.com/openvinotoolkit/openvino/releases/tag/2022.3.0
This commit is contained in:
parent
c2166eea48
commit
85757c2d1b
31
pkgs/development/libraries/openvino/cmake.patch
Normal file
31
pkgs/development/libraries/openvino/cmake.patch
Normal file
@ -0,0 +1,31 @@
|
||||
diff --git a/cmake/developer_package/linux_name.cmake b/cmake/developer_package/linux_name.cmake
|
||||
index 3e8c775770..2d5e00fb8b 100644
|
||||
--- a/cmake/developer_package/linux_name.cmake
|
||||
+++ b/cmake/developer_package/linux_name.cmake
|
||||
@@ -6,25 +6,7 @@ include(target_flags)
|
||||
|
||||
if(LINUX)
|
||||
function(get_linux_name res_var)
|
||||
- if(EXISTS "/etc/lsb-release")
|
||||
- # linux version detection using cat /etc/lsb-release
|
||||
- file(READ "/etc/lsb-release" release_data)
|
||||
- set(name_regex "DISTRIB_ID=([^ \n]*)\n")
|
||||
- set(version_regex "DISTRIB_RELEASE=([0-9]+(\\.[0-9]+)?)")
|
||||
- else()
|
||||
- execute_process(COMMAND find -L /etc/ -maxdepth 1 -type f -name *-release -exec cat {} \;
|
||||
- OUTPUT_VARIABLE release_data
|
||||
- RESULT_VARIABLE result)
|
||||
- string(REPLACE "Red Hat" "CentOS" release_data "${release_data}")
|
||||
- set(name_regex "NAME=\"([^ \"\n]*).*\"\n")
|
||||
- set(version_regex "VERSION=\"([0-9]+(\\.[0-9]+)?)[^\n]*\"")
|
||||
- endif()
|
||||
-
|
||||
- string(REGEX MATCH ${name_regex} name ${release_data})
|
||||
- set(os_name ${CMAKE_MATCH_1})
|
||||
-
|
||||
- string(REGEX MATCH ${version_regex} version ${release_data})
|
||||
- set(os_name "${os_name} ${CMAKE_MATCH_1}")
|
||||
+ set(os_name "NixOS @version@")
|
||||
|
||||
if(os_name)
|
||||
set(${res_var} ${os_name} PARENT_SCOPE)
|
@ -1,115 +1,167 @@
|
||||
{ lib
|
||||
, addOpenGLRunpath
|
||||
, autoPatchelfHook
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, fetchurl
|
||||
, substituteAll
|
||||
|
||||
# build
|
||||
, addOpenGLRunpath
|
||||
, autoPatchelfHook
|
||||
, cmake
|
||||
, git
|
||||
, protobuf
|
||||
, tbb
|
||||
, opencv
|
||||
, unzip
|
||||
, shellcheck
|
||||
, srcOnly
|
||||
, libarchive
|
||||
, pkg-config
|
||||
, python
|
||||
, enablePython ? false
|
||||
, shellcheck
|
||||
|
||||
# runtime
|
||||
, libusb1
|
||||
, libxml2
|
||||
, opencv
|
||||
, protobuf
|
||||
, pugixml
|
||||
, tbb
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
onnx_src = srcOnly {
|
||||
name = "onnx-patched";
|
||||
src = fetchFromGitHub {
|
||||
owner = "onnx";
|
||||
repo = "onnx";
|
||||
rev = "v1.8.1";
|
||||
sha256 = "+1zNnZ4lAyVYRptfk0PV7koIX9FqcfD1Ah33qj/G2rA=";
|
||||
};
|
||||
patches = [
|
||||
# Fix build with protobuf 3.18+
|
||||
# Remove with onnx 1.9 release
|
||||
(fetchpatch {
|
||||
url = "https://github.com/onnx/onnx/commit/d3bc82770474761571f950347560d62a35d519d7.patch";
|
||||
sha256 = "0vdsrklkzhdjaj8wdsl4icn93q3961g8dx35zvff0nhpr08wjb7y";
|
||||
})
|
||||
];
|
||||
# See FIRMWARE_PACKAGE_VERSION in src/plugins/intel_myriad/myriad_dependencies.cmake
|
||||
myriad_firmware_version = "20221129_35";
|
||||
myriad_usb_firmware = fetchurl {
|
||||
url = "https://storage.openvinotoolkit.org/dependencies/myriad/firmware_usb-ma2x8x_${myriad_firmware_version}.zip";
|
||||
hash = "sha256-HKNWbSlMjSafOgrS9WmenbsmeaJKRVssw0NhIwPYZ70=";
|
||||
};
|
||||
myriad_pcie_firmware = fetchurl {
|
||||
url = "https://storage.openvinotoolkit.org/dependencies/myriad/firmware_pcie-ma2x8x_${myriad_firmware_version}.zip";
|
||||
hash = "sha256-VmfrAoKQ++ySIgAxWQul+Hd0p7Y4sTF44Nz4RHpO6Mo=";
|
||||
};
|
||||
|
||||
# See GNA_VERSION in cmake/dependencies.cmake
|
||||
gna_version = "03.00.00.1910";
|
||||
gna = fetchurl {
|
||||
url = "https://storage.openvinotoolkit.org/dependencies/gna/gna_${gna_version}.zip";
|
||||
hash = "sha256-iU3bwK40WfBFE7hTsMq8MokN1Oo3IooCK2oyEBvbt/g=";
|
||||
};
|
||||
|
||||
tbbbind_version = "2_5";
|
||||
tbbbind = fetchurl {
|
||||
url = "https://download.01.org/opencv/master/openvinotoolkit/thirdparty/linux/tbbbind_${tbbbind_version}_static_lin_v2.tgz";
|
||||
hash = "sha256-hl54lMWEAiM8rw0bKIBW4OarK/fJ0AydxgVhxIS8kPQ=";
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "openvino";
|
||||
version = "2021.2";
|
||||
version = "2022.3.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openvinotoolkit";
|
||||
repo = "openvino";
|
||||
rev = version;
|
||||
sha256 = "pv4WTfY1U5GbA9Yj07UOLQifvVH3oDfWptxxYW5IwVQ=";
|
||||
rev = "refs/tags/${version}";
|
||||
fetchSubmodules = true;
|
||||
hash = "sha256-Ie58zTNatiYZZQJ8kJh/+HlSetQjhAtf2Us83z1jGv4=";
|
||||
};
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"python"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
addOpenGLRunpath
|
||||
autoPatchelfHook
|
||||
cmake
|
||||
git
|
||||
libarchive
|
||||
pkg-config
|
||||
(python.withPackages (ps: with ps; [
|
||||
cython
|
||||
pybind11
|
||||
setuptools
|
||||
]))
|
||||
shellcheck
|
||||
];
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./cmake.patch;
|
||||
inherit (lib) version;
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p temp/vpu/firmware/{pcie,usb}-ma2x8x
|
||||
pushd temp/vpu/firmware
|
||||
bsdtar -xf ${myriad_pcie_firmware} -C pcie-ma2x8x
|
||||
echo "${myriad_pcie_firmware.url}" > pcie-ma2x8x/ie_dependency.info
|
||||
bsdtar -xf ${myriad_usb_firmware} -C usb-ma2x8x
|
||||
echo "${myriad_usb_firmware.url}" > usb-ma2x8x/ie_dependency.info
|
||||
popd
|
||||
|
||||
mkdir -p temp/gna_${gna_version}
|
||||
pushd temp/
|
||||
bsdtar -xf ${gna}
|
||||
autoPatchelf gna_${gna_version}
|
||||
echo "${gna.url}" > gna_${gna_version}/ie_dependency.info
|
||||
popd
|
||||
|
||||
mkdir -p temp/tbbbind_${tbbbind_version}
|
||||
pushd temp/tbbbind_${tbbbind_version}
|
||||
bsdtar -xf ${tbbbind}
|
||||
echo "${tbbbind.url}" > ie_dependency.info
|
||||
popd
|
||||
'';
|
||||
|
||||
dontUseCmakeBuildDir = true;
|
||||
|
||||
cmakeFlags = [
|
||||
"-DNGRAPH_USE_SYSTEM_PROTOBUF:BOOL=ON"
|
||||
"-DFETCHCONTENT_FULLY_DISCONNECTED:BOOL=ON"
|
||||
"-DFETCHCONTENT_SOURCE_DIR_EXT_ONNX:STRING=${onnx_src}"
|
||||
"-DENABLE_VPU:BOOL=OFF"
|
||||
"-DTBB_DIR:STRING=${tbb}"
|
||||
"-DCMAKE_PREFIX_PATH:PATH=${placeholder "out"}"
|
||||
"-DCMAKE_MODULE_PATH:PATH=${placeholder "out"}/lib/cmake"
|
||||
"-DENABLE_LTO:BOOL=ON"
|
||||
# protobuf
|
||||
"-DENABLE_SYSTEM_PROTOBUF:BOOL=OFF"
|
||||
"-DProtobuf_LIBRARIES=${protobuf}/lib/libprotobuf${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
# tbb
|
||||
"-DENABLE_SYSTEM_TBB:BOOL=ON"
|
||||
# opencv
|
||||
"-DENABLE_OPENCV:BOOL=ON"
|
||||
"-DOPENCV:STRING=${opencv}"
|
||||
"-DENABLE_GNA:BOOL=OFF"
|
||||
"-DENABLE_SPEECH_DEMO:BOOL=OFF"
|
||||
"-DBUILD_TESTING:BOOL=OFF"
|
||||
"-DENABLE_CLDNN_TESTS:BOOL=OFF"
|
||||
"-DNGRAPH_INTERPRETER_ENABLE:BOOL=ON"
|
||||
"-DNGRAPH_TEST_UTIL_ENABLE:BOOL=OFF"
|
||||
"-DNGRAPH_UNIT_TEST_ENABLE:BOOL=OFF"
|
||||
"-DENABLE_SAMPLES:BOOL=OFF"
|
||||
"-DENABLE_CPPLINT:BOOL=OFF"
|
||||
] ++ lib.optionals enablePython [
|
||||
"-DOpenCV_DIR=${opencv}/lib/cmake/opencv4/"
|
||||
# pugixml
|
||||
"-DENABLE_SYSTEM_PUGIXML:BOOL=ON"
|
||||
# onednn
|
||||
"-DENABLE_ONEDNN_FOR_GPU:BOOL=OFF"
|
||||
# intel gna
|
||||
"-DENABLE_INTEL_GNA:BOOL=ON"
|
||||
# python
|
||||
"-DENABLE_PYTHON:BOOL=ON"
|
||||
# tests
|
||||
"-DENABLE_CPPLINT:BOOL=OFF"
|
||||
"-DBUILD_TESTING:BOOL=OFF"
|
||||
"-DENABLE_SAMPLES:BOOL=OFF"
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
# To make install openvino inside /lib instead of /python
|
||||
substituteInPlace inference-engine/ie_bridges/python/CMakeLists.txt \
|
||||
--replace 'DESTINATION python/''${PYTHON_VERSION}/openvino' 'DESTINATION lib/''${PYTHON_VERSION}/site-packages/openvino' \
|
||||
--replace 'DESTINATION python/''${PYTHON_VERSION}' 'DESTINATION lib/''${PYTHON_VERSION}/site-packages/openvino'
|
||||
substituteInPlace inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt \
|
||||
--replace 'python/''${PYTHON_VERSION}/openvino/inference_engine' 'lib/''${PYTHON_VERSION}/site-packages/openvino/inference_engine'
|
||||
|
||||
# Used to download OpenCV based on Linux Distro and make it use system OpenCV
|
||||
substituteInPlace inference-engine/cmake/dependencies.cmake \
|
||||
--replace 'include(linux_name)' ' ' \
|
||||
--replace 'if (ENABLE_OPENCV)' 'if (ENABLE_OPENCV AND NOT DEFINED OPENCV)'
|
||||
|
||||
cmakeDir=$PWD
|
||||
mkdir ../build
|
||||
cd ../build
|
||||
'';
|
||||
|
||||
autoPatchelfIgnoreMissingDeps = [ "libngraph_backend.so" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
autoPatchelfHook
|
||||
addOpenGLRunpath
|
||||
unzip
|
||||
autoPatchelfIgnoreMissingDeps = [
|
||||
"libngraph_backend.so"
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
git
|
||||
protobuf
|
||||
libusb1
|
||||
libxml2
|
||||
opencv
|
||||
python
|
||||
protobuf
|
||||
pugixml
|
||||
tbb
|
||||
shellcheck
|
||||
] ++ lib.optionals enablePython (with python.pkgs; [
|
||||
cython
|
||||
pybind11
|
||||
]);
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postInstall = ''
|
||||
pushd $out/python/python${lib.versions.majorMinor python.version}
|
||||
mkdir -p $python
|
||||
mv ./* $python/
|
||||
popd
|
||||
rm -r $out/python
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# Link to OpenCL
|
||||
@ -130,8 +182,7 @@ stdenv.mkDerivation rec {
|
||||
homepage = "https://docs.openvinotoolkit.org/";
|
||||
license = with licenses; [ asl20 ];
|
||||
platforms = platforms.all;
|
||||
broken = (stdenv.isLinux && stdenv.isx86_64) # at 2022-09-23
|
||||
|| stdenv.isDarwin; # Cannot find macos sdk
|
||||
broken = stdenv.isDarwin; # Cannot find macos sdk
|
||||
maintainers = with maintainers; [ tfmoraes ];
|
||||
};
|
||||
}
|
||||
|
40
pkgs/development/python-modules/openvino/default.nix
Normal file
40
pkgs/development/python-modules/openvino/default.nix
Normal file
@ -0,0 +1,40 @@
|
||||
{ lib
|
||||
, buildPythonPackage
|
||||
, openvino-native
|
||||
, numpy
|
||||
, python
|
||||
}:
|
||||
|
||||
buildPythonPackage {
|
||||
pname = "openvino";
|
||||
inherit (openvino-native) version;
|
||||
format = "other";
|
||||
|
||||
src = openvino-native.python;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
numpy
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/${python.sitePackages}
|
||||
cp -Rv * $out/${python.sitePackages}/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
pythonImportsCheck = [
|
||||
"ngraph"
|
||||
"openvino"
|
||||
"openvino.runtime"
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "OpenVINO(TM) Runtime";
|
||||
homepage = "https://github.com/openvinotoolkit/openvino";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ hexa ];
|
||||
};
|
||||
}
|
@ -38714,8 +38714,9 @@ with pkgs;
|
||||
|
||||
openring = callPackage ../applications/misc/openring { };
|
||||
|
||||
openvino = callPackage ../development/libraries/openvino
|
||||
{ stdenv = gcc10StdenvCompat; python = python3; };
|
||||
openvino = callPackage ../development/libraries/openvino {
|
||||
python = python3;
|
||||
};
|
||||
|
||||
phonetisaurus = callPackage ../development/libraries/phonetisaurus {
|
||||
# https://github.com/AdolfVonKleist/Phonetisaurus/issues/70
|
||||
|
@ -6696,10 +6696,11 @@ self: super: with self; {
|
||||
|
||||
opentracing = callPackage ../development/python-modules/opentracing { };
|
||||
|
||||
openvino = toPythonModule (pkgs.openvino.override {
|
||||
inherit (self) python;
|
||||
enablePython = true;
|
||||
});
|
||||
openvino = callPackage ../development/python-modules/openvino {
|
||||
openvino-native = pkgs.openvino.override {
|
||||
inherit python;
|
||||
};
|
||||
};
|
||||
|
||||
openwebifpy = callPackage ../development/python-modules/openwebifpy { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user