全能電路設計實戰

2019年5月6日 星期一

OpenVINO教學-OpenVINO model optimizer錯誤排解


www.ittraining.com.tw狀況一、OpenVINO model optimizer 發生內部錯誤

當使用Intel OpenVINO model optimizer 轉換tensorflow pb modelIR (Intermediate Representation) model時出現…… Exception occurred during running replacer "REPLACEMENT_ID (<……>)": list index out of range ……等訊息。


    









        出現此現象表示輸入之pb model可能未進行Freeze動作或Freeze動作未完全,故可參考
https://stackoverflow.com/questions/45466020/how-to-export-keras-h5-to-tensorflow-pb將整個tensorflow session完全freeze,再行轉換即可成功。

Reference:

    
狀況二、使用OpenVINO model optimizer 出現 __new__() got an unexpected keyword argument 'serialized_options' 錯誤

      當使用Intel OpenVINO model optimizer 轉換tensorflow pb model至IR (Intermediate Representation) model時出現以下錯誤訊息:

[ ERROR ]  Error happened while importing tensorflow module. It may happen due to unsatisfied requirements of that module. Please run requirements installation script once more.
Details on module importing failure: __new__() got an unexpected keyword argument 'serialized_options'

[ ERROR ]

Detected not satisfied dependencies:
        tensorflow: package error, required: 1.10.0

表示系統所安裝之protoc(Protocol Buffer) binary與python protobuf package版本不一致所致。可使用以下3組指令確認系統目前所安裝之版本。

1.系統Global protoc binary version
protoc --version

2.使用pip所安裝之版本
pip list|grep protobuf

3.python3 interpreter實際抓到使用的版本
python3 -c "from google import protobuf;print(protobuf.__version__);print(protobuf.__file__)"

















指令1更版方式:
#Make sure you grab the latest version
wget 
https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip

# Unzip
unzip protoc-3.7.1-linux-x86_64.zip -d protoc3.7.1

# Detemine Directory, if exist delete it
if [ -d " protoc3.7.1" ]; then
    # Directory protoc3.7.1 exists
    echo "Directory protoc3.7.1 exists. Remove it."
    sudo rm -r protoc3.7.1
fi

# Move protoc to /usr/local/bin/
sudo mv protoc3.7.1/bin/* /usr/local/bin/

# Detemine Directory, if exist delete it
if [ -d "/usr/local/include/google" ]; then
    # Directory /usr/local/include/google exists
    echo "Directory /usr/local/include/google exists. Remove it."
    sudo rm -r /usr/local/include/google
fi

# Move protoc3/include to /usr/local/include/
sudo mv protoc3.7.1/include/* /usr/local/include/

# Optional: change owner
sudo chown $USER /usr/local/bin/protoc
sudo chown -R $USER /usr/local/include/google

# Delete protoc3.7.1 directory
rm -r protoc3.7.1

指令2更版方式:
Pip install -U -force-reinstall protobuf==3.7.1

指令3更版方式:
若dist-package有使用easy-install (EGG)安裝之套件,則依該套件的方法移除後重新執行指令2的更版方式即可修復

~強烈建議在Linux環境下使用virtualenv、Windows環境下使用anaconda做python環境控管~