机器学习环境配置——Openvino安装

本文主要记录openvino的安装验证步骤、安装中遇到的问题。
openvino:2021.1
python:3.6.5(根据时间哈,现在2021年建议3.6.5,因为之前安装高版本有出一些问题)
Microsoft Visual Studio 2019
CMake:3.14.6

1.安装前需要的环境

建议在安装openvino之前配置好这些环境。(如下图所示)
查看版本需要的配置
在这里插入图片描述

2.官网下载

点击跳转下载openvino程序
进入官网如下图所示:
在这里插入图片描述
会需要注册填写一些信息,然后就可以下载程序了。

3.双击exe程序安装

双击下载的exe程序
在这里插入图片描述

(1)选择解压压缩包保存的地址,可以勾选选择是否在安装之后删除临时解压的文件。
在这里插入图片描述

(2)选择安装的内容和安装地址(强烈建议!!!不要修改默认安装路径,经历过修改重装后有的感受,但也可能是下载版本过新之类的问题),可以直接点击next。

在这里插入图片描述

(3)点击Next.在这里插入图片描述

(4)点击Next.
在这里插入图片描述

4.配置

(1)电脑搜索框输入cmd进入命令行
在这里插入图片描述

(2)初始化openvino
这里的初始化是每次进入openvino都需要设置的,关闭这个窗口就失效了,可以搜索网上教程进行全局环境变量配置。

cd C:\Program Files (x86)\Intel\openvino_2021.1.110\bin
.\setupvars.bat

在这里插入图片描述

(3)配置Model Optimizer

  • 进入目录
cd C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\install_prerequisites
  • 安装全部openvino支持的全部框架(onnx , tensorflow1 , tensorflow2 , maxnet , caffe , kaldi)
.\install_prerequisites.bat

全部安装成功提示如图所示:
在这里插入图片描述
可以命令行输入以下进行验证:

python
>>>import onnx
>>>import tensorflow

【tips】
增加下载安装速度,进入以下路径(前面一部分C:\Program Files (x86)\Intel\openvino_2021.1.110是安装路径)

C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\install_prerequisites

找到文件:在这里插入图片描述
第81行可以看到是使用pip进行下载,所以可以在命令后面加上

-i 国内镜像源(清华、阿里等)
例:-i https://pypi.tuna.tsinghua.edu.cn/simple

添加完毕如下图所示,如果不能修改成功,用管理员身份打开运行即可。
在这里插入图片描述

  • 选择部分安装

tensorflow1(1,2所支持的python版本不同)

.\install_prerequisites_tf.bat

tensorflow2

.\install_prerequisites_tf2.bat

caffe

.\install_prerequisites_caffe.bat

onnx

.\install_prerequisites_onnx.bat

mxnet

.\install_prerequisites_mxnet.bat

kaldi

.\install_prerequisites_kaldi.bat

(4)可能遇到的问题
下载速度过慢导致报错,可尝试上面添加镜像源的方式解决。

5.验证

(1)成功过程
a. 配置下载完成后继续进行验证,输入以下命令:

cd C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo

.\demo_squeezenet_download_convert_run.bat

成功会得到以下结果:
在这里插入图片描述
完整过程记录如下,分析过程包括以下几个阶段(复制粘贴CMD里的内容):

  • Install Model Optimizer prerequisites 下载安装
  • Run Model Optimizer 运行
  • ===Converting squeezenet1.1 to IR (FP16)
  • Generate VS solution for Inference Engine samples using cmake
  • Build Inference Engine samples using MS Visual Studio (MSBuild.exe)
  • Run Inference Engine classification sample
  • Classification demo completed successfully
C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo>.\demo_squeezenet_download_convert_run.bat
target_precision = FP16
Python 3.6.5
[setupvars.bat] OpenVINO environment initialized
INTEL_OPENVINO_DIR is set to C:\Program Files (x86)\Intel\openvino_2021.1.110
Python 3.6.5
ECHO 处于关闭状态。
Requirement already satisfied: pyyaml in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 1))
Requirement already satisfied: requests in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 2))
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\hp\appdata\roaming\python\python36\site-packages (from requests->-r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 2))
Requirement already satisfied: certifi>=2017.4.17 in c:\users\hp\appdata\roaming\python\python36\site-packages (from requests->-r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 2))
Requirement already satisfied: idna<2.7,>=2.5 in c:\users\hp\appdata\roaming\python\python36\site-packages (from requests->-r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 2))
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\users\hp\appdata\roaming\python\python36\site-packages (from requests->-r C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\..\open_model_zoo\tools\downloader\requirements.in (line 2))
You are using pip version 9.0.3, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Download public squeezenet1.1 model
python "C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\open_model_zoo\tools\downloader\downloader.py" --name "squeezenet1.1" --output_dir "C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models" --cache_dir "C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\cache"
squeezenet1.1 model downloading completed

等待 0 秒,按一个键继续 ...

###############|| Install Model Optimizer prerequisites ||###############


等待 0 秒,按一个键继续 ...
Python 3.6.5
ECHO 处于关闭状态。
Requirement already satisfied: networkx>=1.11 in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r ..\requirements_caffe.txt (line 1))
Requirement already satisfied: numpy>=1.13.0 in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r ..\requirements_caffe.txt (line 2))
Requirement already satisfied: protobuf>=3.6.1 in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r ..\requirements_caffe.txt (line 3))
Requirement already satisfied: test-generator==0.1.1 in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r ..\requirements_caffe.txt (line 4))
Requirement already satisfied: defusedxml>=0.5.0 in c:\users\hp\appdata\roaming\python\python36\site-packages (from -r ..\requirements_caffe.txt (line 5))
Requirement already satisfied: decorator>=4.3.0 in c:\users\hp\appdata\roaming\python\python36\site-packages (from networkx>=1.11->-r ..\requirements_caffe.txt (line 1))
Requirement already satisfied: six>=1.9 in c:\users\hp\appdata\roaming\python\python36\site-packages (from protobuf>=3.6.1->-r ..\requirements_caffe.txt (line 3))
You are using pip version 9.0.3, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
*****************************************************************************************
Warning: please expect that Model Optimizer conversion might be slow.
You can boost conversion speed by installing protobuf-*.egg located in the
"model-optimizer\install_prerequisites" folder or building protobuf library from sources.
For more information please refer to Model Optimizer FAQ, question #80.

等待 0 秒,按一个键继续 ...

###############|| Run Model Optimizer ||###############


等待 0 秒,按一个键继续 ...
python "C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\open_model_zoo\tools\downloader\converter.py" --mo "C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\mo.py" --name "squeezenet1.1" -d "C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models" -o "C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir" --precisions "FP16"
========== Converting squeezenet1.1 to IR (FP16)
Conversion command: I:\software\python\python-3.6.5-64\install\python.exe -- "C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\mo.py" --framework=caffe --data_type=FP16 --output_dir=C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir\public\squeezenet1.1\FP16 --model_name=squeezenet1.1 --input_shape=[1,3,227,227] --input=data --mean_values=data[104.0,117.0,123.0] --output=prob --input_model=C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.caffemodel --input_proto=C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.prototxt

Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.caffemodel
        - Path for generated IR:        C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir\public\squeezenet1.1\FP16
        - IR output name:       squeezenet1.1
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         data
        - Output layers:        prob
        - Input shapes:         [1,3,227,227]
        - Mean values:  data[104.0,117.0,123.0]
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP16
        - Enable fusing:        True
        - Enable grouped convolutions fusing:   True
        - Move mean values to preprocess section:       None
        - Reverse input channels:       False
Caffe specific parameters:
        - Path to Python Caffe* parser generated from caffe.proto:      C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\mo\front\caffe\proto
        - Enable resnet optimization:   True
        - Path to the Input prototxt:   C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.prototxt
        - Path to CustomLayersMapping.xml:      C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\extensions\front\caffe\CustomLayersMapping.xml
        - Path to a mean file:  Not specified
        - Offsets for a mean file:      Not specified
Model Optimizer version:        2021.1.0-1237-bece22ac675-releases/2021/1

[ SUCCESS ] Generated IR version 10 model.
[ SUCCESS ] XML file: C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir\public\squeezenet1.1\FP16\squeezenet1.1.xml
[ SUCCESS ] BIN file: C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir\public\squeezenet1.1\FP16\squeezenet1.1.bin
[ SUCCESS ] Total execution time: 7.48 seconds.
It's been a while, check for a new version of Intel(R) Distribution of OpenVINO(TM) toolkit here https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/choose-download.html?cid=other&source=Prod&campid=ww_2020_bu_IOTG_OpenVINO-2021-1&content=upg_pro&medium=organic_uid_agjj or on the GitHub*


等待 0 秒,按一个键继续 ...

###############|| Generate VS solution for Inference Engine samples using cmake ||###############


等待 0 秒,按一个键继续 ...
Creating Visual Studio 16 2019 x64 files in C:\Users\HP\Documents\Intel\OpenVINO\inference_engine_samples_build...
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Check for working C compiler: I:/software/visual studio/buildtools-visualStudio-2019/install/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: I:/software/visual studio/buildtools-visualStudio-2019/install/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: I:/software/visual studio/buildtools-visualStudio-2019/install/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: I:/software/visual studio/buildtools-visualStudio-2019/install/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found InferenceEngine: C:/Program Files (x86)/Intel/openvino_2021.1.110/deployment_tools/inference_engine/lib/intel64/Release/inference_engine.lib (Required is at least version "2.1")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/HP/Documents/Intel/OpenVINO/inference_engine_samples_build

等待 0 秒,按一个键继续 ...

###############|| Build Inference Engine samples using MS Visual Studio (MSBuild.exe) ||###############


等待 0 秒,按一个键继续 ...
"I:\software\visual studio\buildtools-visualStudio-2019\install\MSBuild\Current\Bin\MSBuild.exe" Samples.sln /p:Configuration=Release /t:cpp_samples\classification_sample_async /clp:ErrorsOnly /m
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.9.0+57a23d249
版权所有(C) Microsoft Corporation。保留所有权利。


等待 0 秒,按一个键继续 ...

###############|| Run Inference Engine classification sample ||###############


等待 0 秒,按一个键继续 ...
已复制         1 个文件。
classification_sample_async.exe -i "C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\car.png" -m "C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\ir\public\squeezenet1.1\FP16\squeezenet1.1.xml" -d CPU
[ INFO ] InferenceEngine:
        API version ............ 2.1
        Build .................. 2021.1.0-1237-bece22ac675-releases/2021/1
        Description ....... API
[ INFO ] Parsing input parameters
[ INFO ] Parsing input parameters
[ INFO ] Files were added: 1
[ INFO ]     C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\car.png
[ INFO ] Creating Inference Engine
        CPU
        MKLDNNPlugin version ......... 2.1
        Build ........... 2021.1.0-1237-bece22ac675-releases/2021/1

[ INFO ] Loading network files
[ INFO ] Preparing input blobs
[ WARNING ] Image is resized from (787, 259) to (227, 227)
[ INFO ] Batch size is 1
[ INFO ] Loading model to the device
[ INFO ] Create infer request
[ INFO ] Start inference (10 asynchronous executions)
[ INFO ] Completed 1 async request execution
[ INFO ] Completed 2 async request execution
[ INFO ] Completed 3 async request execution
[ INFO ] Completed 4 async request execution
[ INFO ] Completed 5 async request execution
[ INFO ] Completed 6 async request execution
[ INFO ] Completed 7 async request execution
[ INFO ] Completed 8 async request execution
[ INFO ] Completed 9 async request execution
[ INFO ] Completed 10 async request execution
[ INFO ] Processing output blobs

Top 10 results:

Image C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\car.png

classid probability label
------- ----------- -----
817     0.6853030   sports car, sport car
479     0.1835197   car wheel
511     0.0917197   convertible
436     0.0200694   beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
751     0.0069604   racer, race car, racing car
656     0.0044177   minivan
717     0.0024739   pickup, pickup truck
581     0.0017788   grille, radiator grille
468     0.0013083   cab, hack, taxi, taxicab
661     0.0007443   Model T

[ INFO ] Execution successful

[ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool

###############|| Classification demo completed successfully ||###############

等待  0 秒,按一个键继续 ...

b. 运行查看demo,cmd输入以下命令

.\demo_security_barrier_camera.bat

成功如下图所示:
在这里插入图片描述

(2)失败遇到的问题

  • Error:The “C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.caffemodel” is not existing file
    FAILED:
    squeezenet1.1

在这里插入图片描述
【错误原因】下载squeezenet模型失败
【解决方法】
(本解决方法转载自:https://blog.csdn.net/dou3516/article/details/107087386)
通过路径C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo找到文件:demo_squeezenet_download_convert_run.bat ,以管理员身份打开,注释掉第102行,如下图所示:
在这里插入图片描述
在网址:https://github.com/opencv/open_model_zoo/tree/master/models/public/squeezenet1.1下载好这个模型,复制文件在这里插入图片描述到目录:C:\Users\HP\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1

  • Error:[ FRAMEWORK ERROR ] Exception message: cannot mmap an empty file
    在这里插入图片描述
    【错误原因】squeezenet1.1.caffemodel文件为空。
    【解决方法】按照上面那个error的解决方法,把正确文件复制过去并修改文件名正确即可

  • Error:‘vswhere’ 不是内部或外部命令,也不是可运行的程序或批处理文件。
    在这里插入图片描述
    【错误原因】猜测和修改openvino安装路径有关系
    【解决方法】重装openvino(以默认路径)

  • Build tools for Visual Studio 2015 / 2017 / 2019 cannot be found. If you use Visual Studio 2017, please download and install build tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
    Error
    在这里插入图片描述
    【错误原因】没有安装vs对应的buildtools
    【解决方法】
    进入网址点击进入官方下载地址下载对应版本的buildTools(位置如下图所示),然后安装即可。
    在这里插入图片描述
    在这里插入图片描述

  • 记得还有一个错误是因为FP16文件夹已存在,删掉即可,是由于上次运行未成功但已经建了这个文件夹,还没来得及转换程序就停止了。(奇怪,没有找到记录只能口述了)

最后记录一下自己经历的过程:
以前安装好的python3.8+vs2019——> 安装Cmake3.18.6——>安装openvino(修改了默认安装路径)——>卸载CMake3.18.6,安装CMake3.14.6——>卸载python3.8,安装python3.6.5——>卸载openvino(以默认路径)——>安装vs2019 build tools

参考:
1.openvino下载地址:
https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/choose-download/windows.html
2.openvino官方安装文档:https://docs.openvinotoolkit.org/cn/latest/openvino_docs_install_guides_installing_openvino_windows.html
3.配置安装
https://www.cnblogs.com/ag-chen/articles/13490648.html
https://blog.csdn.net/heiheiya/article/details/91387199
4.配置永久环境变量:
https://www.freesion.com/article/9501660091/
5.Error:vswhere 不是内部或外部命令,又不是可运行程序https://blog.csdn.net/chen798213337/article/details/95652601
6.Error:squeezenet1.1模型下载失败
https://blog.csdn.net/dou3516/article/details/107087386

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值