Skip to content

Commit f935d5c

Browse files
authored
remove checking vs existing for pytorch quantization (openvinotoolkit#1799)
1 parent 623715b commit f935d5c

File tree

2 files changed

+10
-165
lines changed

2 files changed

+10
-165
lines changed

notebooks/112-pytorch-post-training-quantization-nncf/112-pytorch-post-training-quantization-nncf.ipynb

+8-104
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"cells": [
33
{
4-
"attachments": {},
54
"cell_type": "markdown",
65
"metadata": {},
76
"source": [
@@ -20,7 +19,8 @@
2019
"> **NOTE**: This notebook requires that a C++ compiler is accessible on the default binary search path of the OS you are running the notebook.\n",
2120
"\n",
2221
"\n",
23-
"#### Table of contents:\n\n",
22+
"#### Table of contents:\n",
23+
"\n",
2424
"- [Preparations](#Preparations)\n",
2525
" - [Imports](#Imports)\n",
2626
" - [Settings](#Settings)\n",
@@ -38,7 +38,6 @@
3838
]
3939
},
4040
{
41-
"attachments": {},
4241
"cell_type": "markdown",
4342
"metadata": {},
4443
"source": [
@@ -53,57 +52,11 @@
5352
"outputs": [],
5453
"source": [
5554
"# Install openvino package\n",
56-
"%pip install -q \"openvino>=2023.1.0\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu\n",
57-
"%pip install -q \"nncf>=2.6.0\""
58-
]
59-
},
60-
{
61-
"cell_type": "code",
62-
"execution_count": 2,
63-
"metadata": {
64-
"scrolled": true,
65-
"tags": []
66-
},
67-
"outputs": [],
68-
"source": [
69-
"# On Windows, this script adds the directory that contains cl.exe to the PATH to enable PyTorch to find the\n",
70-
"# required C++ tools. This code assumes that Visual Studio 2019 is installed in the default\n",
71-
"# directory. If you have a different C++ compiler, add the correct path to os.environ[\"PATH\"]\n",
72-
"# directly.\n",
73-
"\n",
74-
"# Adding the path to os.environ[\"LIB\"] is not always required - it depends on the system configuration.\n",
75-
"\n",
76-
"import sys\n",
77-
"\n",
78-
"if sys.platform == \"win32\":\n",
79-
" import distutils.command.build_ext\n",
80-
" import os\n",
81-
" from pathlib import Path\n",
82-
"\n",
83-
" VS_INSTALL_DIR = r\"C:/Program Files (x86)/Microsoft Visual Studio\"\n",
84-
" cl_paths = sorted(list(Path(VS_INSTALL_DIR).glob(\"**/Hostx86/x64/cl.exe\")))\n",
85-
" if len(cl_paths) == 0:\n",
86-
" raise ValueError(\n",
87-
" \"Cannot find Visual Studio. This notebook requires C++. If you installed \"\n",
88-
" \"a C++ compiler, please add the directory that contains cl.exe to \"\n",
89-
" \"`os.environ['PATH']`\"\n",
90-
" )\n",
91-
" else:\n",
92-
" # If multiple versions of MSVC are installed, get the most recent one.\n",
93-
" cl_path = cl_paths[-1]\n",
94-
" vs_dir = str(cl_path.parent)\n",
95-
" os.environ[\"PATH\"] += f\"{os.pathsep}{vs_dir}\"\n",
96-
" # The code for finding the library dirs is from\n",
97-
" # https://stackoverflow.com/questions/47423246/get-pythons-lib-path\n",
98-
" d = distutils.core.Distribution()\n",
99-
" b = distutils.command.build_ext.build_ext(d)\n",
100-
" b.finalize_options()\n",
101-
" os.environ[\"LIB\"] = os.pathsep.join(b.library_dirs)\n",
102-
" print(f\"Added {vs_dir} to PATH\")"
55+
"%pip install -q \"openvino>=2024.0.0\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu\n",
56+
"%pip install -q \"nncf>=2.9.0\""
10357
]
10458
},
10559
{
106-
"attachments": {},
10760
"cell_type": "markdown",
10861
"metadata": {},
10962
"source": [
@@ -146,7 +99,6 @@
14699
]
147100
},
148101
{
149-
"attachments": {},
150102
"cell_type": "markdown",
151103
"metadata": {},
152104
"source": [
@@ -206,7 +158,6 @@
206158
]
207159
},
208160
{
209-
"attachments": {},
210161
"cell_type": "markdown",
211162
"metadata": {},
212163
"source": [
@@ -264,7 +215,6 @@
264215
]
265216
},
266217
{
267-
"attachments": {},
268218
"cell_type": "markdown",
269219
"metadata": {},
270220
"source": [
@@ -340,7 +290,6 @@
340290
]
341291
},
342292
{
343-
"attachments": {},
344293
"cell_type": "markdown",
345294
"metadata": {},
346295
"source": [
@@ -404,7 +353,6 @@
404353
]
405354
},
406355
{
407-
"attachments": {},
408356
"cell_type": "markdown",
409357
"metadata": {},
410358
"source": [
@@ -441,7 +389,6 @@
441389
]
442390
},
443391
{
444-
"attachments": {},
445392
"cell_type": "markdown",
446393
"metadata": {},
447394
"source": [
@@ -507,7 +454,6 @@
507454
]
508455
},
509456
{
510-
"attachments": {},
511457
"cell_type": "markdown",
512458
"metadata": {},
513459
"source": [
@@ -518,7 +464,6 @@
518464
]
519465
},
520466
{
521-
"attachments": {},
522467
"cell_type": "markdown",
523468
"metadata": {},
524469
"source": [
@@ -557,7 +502,6 @@
557502
]
558503
},
559504
{
560-
"attachments": {},
561505
"cell_type": "markdown",
562506
"metadata": {},
563507
"source": [
@@ -569,7 +513,6 @@
569513
]
570514
},
571515
{
572-
"attachments": {},
573516
"cell_type": "markdown",
574517
"metadata": {},
575518
"source": [
@@ -596,7 +539,6 @@
596539
]
597540
},
598541
{
599-
"attachments": {},
600542
"cell_type": "markdown",
601543
"metadata": {},
602544
"source": [
@@ -639,7 +581,6 @@
639581
]
640582
},
641583
{
642-
"attachments": {},
643584
"cell_type": "markdown",
644585
"metadata": {},
645586
"source": [
@@ -674,15 +615,13 @@
674615
]
675616
},
676617
{
677-
"attachments": {},
678618
"cell_type": "markdown",
679619
"metadata": {},
680620
"source": [
681621
"It should be noted that the inference time for the quantized PyTorch model is longer than that of the original model, as fake quantizers are added to the model by NNCF. However, the model's performance will significantly improve when it is in the OpenVINO Intermediate Representation (IR) format."
682622
]
683623
},
684624
{
685-
"attachments": {},
686625
"cell_type": "markdown",
687626
"metadata": {},
688627
"source": [
@@ -759,7 +698,6 @@
759698
]
760699
},
761700
{
762-
"attachments": {},
763701
"cell_type": "markdown",
764702
"metadata": {},
765703
"source": [
@@ -806,7 +744,6 @@
806744
]
807745
},
808746
{
809-
"attachments": {},
810747
"cell_type": "markdown",
811748
"metadata": {},
812749
"source": [
@@ -881,7 +818,6 @@
881818
]
882819
},
883820
{
884-
"attachments": {},
885821
"cell_type": "markdown",
886822
"metadata": {},
887823
"source": [
@@ -972,7 +908,6 @@
972908
]
973909
},
974910
{
975-
"attachments": {},
976911
"cell_type": "markdown",
977912
"metadata": {},
978913
"source": [
@@ -1018,7 +953,7 @@
1018953
"provenance": []
1019954
},
1020955
"kernelspec": {
1021-
"display_name": "Python 3",
956+
"display_name": "Python 3 (ipykernel)",
1022957
"language": "python",
1023958
"name": "python3"
1024959
},
@@ -1032,7 +967,7 @@
1032967
"name": "python",
1033968
"nbconvert_exporter": "python",
1034969
"pygments_lexer": "ipython3",
1035-
"version": "3.11.5"
970+
"version": "3.8.10"
1036971
},
1037972
"openvino_notebooks": {
1038973
"imageUrl": "",
@@ -1055,43 +990,12 @@
1055990
},
1056991
"widgets": {
1057992
"application/vnd.jupyter.widget-state+json": {
1058-
"state": {
1059-
"5ba51a4155a94f2f9b2021414519d2fd": {
1060-
"model_module": "@jupyter-widgets/base",
1061-
"model_module_version": "2.0.0",
1062-
"model_name": "LayoutModel",
1063-
"state": {}
1064-
},
1065-
"88897c3f697f4cef82e9b7c3e0064fa4": {
1066-
"model_module": "@jupyter-widgets/controls",
1067-
"model_module_version": "2.0.0",
1068-
"model_name": "DescriptionStyleModel",
1069-
"state": {
1070-
"description_width": ""
1071-
}
1072-
},
1073-
"e4be0e28604d4474ba58bb32a06e4514": {
1074-
"model_module": "@jupyter-widgets/controls",
1075-
"model_module_version": "2.0.0",
1076-
"model_name": "DropdownModel",
1077-
"state": {
1078-
"_options_labels": [
1079-
"CPU",
1080-
"GPU",
1081-
"AUTO"
1082-
],
1083-
"description": "Device:",
1084-
"index": 2,
1085-
"layout": "IPY_MODEL_5ba51a4155a94f2f9b2021414519d2fd",
1086-
"style": "IPY_MODEL_88897c3f697f4cef82e9b7c3e0064fa4"
1087-
}
1088-
}
1089-
},
993+
"state": {},
1090994
"version_major": 2,
1091995
"version_minor": 0
1092996
}
1093997
}
1094998
},
1095999
"nbformat": 4,
10961000
"nbformat_minor": 4
1097-
}
1001+
}

0 commit comments

Comments
 (0)