Remove sudo from mo install_prerequisites.sh (#6378)

* Remove sudo from mo install_prerequisites.sh

* Move venv folder to $HOME dir

* Wrap $venv_python_binary with double quotes

* Add variable to store `$HOME/venv_mo`

* Use one venv for all OpenVINO tools

* Add ROOT_DIR variable

* Add python venv creation

* Add message about venv to the .bat script

* Fix a typo
This commit is contained in:
Dmitry Pigasin authored and GitHub committed 2021-07-08 17:10:00 +03:00
1 parent 975496df16
commit 8b52a4c0c5
2 files changed
+53 -38

No files matched your search

@@ -6,6 +6,8 @@
:: Check if Python is installed
setlocal
set ROOT_DIR=%~dp0
python --version 2>NUL
if errorlevel 1 (
echo Error^: Python is not installed. Please install Python 3.5 ^(64-bit^) or higher from https://www.python.org/downloads/
@@ -35,10 +37,16 @@ if not "%python_ver%"=="okay" (
:: install Python modules
set USE_VENV="false"
set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino
IF /I "%1%" EQU "" (
set postfix=
) ELSE (
IF /I "%1%" EQU "venv" (
set postfix=
set USE_VENV="true"
) ELSE (
IF /I "%1%" EQU "caffe" (
set postfix=_caffe
) ELSE (
@@ -59,6 +67,7 @@ IF /I "%1%" EQU "" (
) ELSE (
echo Unsupported framework
goto error
)
)
)
)
@@ -67,10 +76,20 @@ IF /I "%1%" EQU "" (
)
)
pip3 install --user -r ..\requirements%postfix%.txt
IF /I "%2%" EQU "venv" (
set USE_VENV="true"
)
IF %USE_VENV% == "true" (
python -m venv "%VENV_DIR%"
call "%VENV_DIR%\Scripts\activate.bat"
)
python -m pip install -U pip
python -m pip install -r "%ROOT_DIR%..\requirements%postfix%.txt"
:: Chek MO version
set python_command='python "%~dp0..\mo\utils\extract_release_version.py"'
set python_command='python "%ROOT_DIR%..\mo\utils\extract_release_version.py"'
FOR /F "delims=" %%i IN (%python_command%) DO set mo_release_version=%%i
IF "%mo_release_version%" == "None.None" (
set mo_is_custom="true"
@@ -80,12 +99,12 @@ IF "%mo_release_version%" == "None.None" (
:: Check if existing IE Python bindings satisfy requirements
set errorlevel=
python "%~dp0..\mo\utils\find_ie_version.py"
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
IF %errorlevel% EQU 0 goto ie_search_end
:: Check if OV already installed via pip
set errorlevel=
pip3 show openvino
python -m pip show openvino
IF %errorlevel% EQU 0 (
IF %mo_is_custom% == "true" (
echo [ WARNING ] OpenVINO ^(TM^) Toolkit version installed in pip is incompatible with the Model Optimizer
@@ -110,7 +129,7 @@ IF %mo_is_custom% == "true" (
)
set errorlevel=
pip3 install openvino==%mo_release_version%
python -m pip install openvino==%mo_release_version%
IF %errorlevel% NEQ 0 (
echo [ WARNING ] Could not find the OpenVINO ^(TM^) toolkit version %mo_release_version% in pip
echo [ WARNING ] The highest OpenVINO ^(TM^) toolkit version will be installed ^(may be incompatible with current Model Optimizer version^)
@@ -119,17 +138,17 @@ IF %errorlevel% NEQ 0 (
)
set errorlevel=
python "%~dp0..\mo\utils\find_ie_version.py"
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
IF %errorlevel% EQU 0 goto ie_search_end
echo [ WARNING ] The installed OpenVINO ^(TM^) toolkit version %mo_release_version% does not work as expected. Uninstalling...
pip3 uninstall -y openvino
python -m pip uninstall -y openvino
echo [ WARNING ] Consider building the Inference Engine Python API from sources
goto ie_search_end
:install_last_ov
set errorlevel=
pip3 install openvino
python -m pip install openvino
IF %errorlevel% NEQ 0 (
echo [ WARNING ] Could not find OpenVINO ^(TM^) toolkit version available in pip for installation
echo [ WARNING ] Consider building the Inference Engine Python API from sources
@@ -137,16 +156,26 @@ IF %errorlevel% NEQ 0 (
)
set errorlevel=
python "%~dp0..\mo\utils\find_ie_version.py"
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
IF %errorlevel% EQU 0 goto ie_search_end
echo [ WARNING ] The installed highest OpenVINO ^(TM^) toolkit version doesn't work as expected. Uninstalling...
pip3 uninstall -y openvino
python -m pip uninstall -y openvino
echo [ WARNING ] Consider building the Inference Engine Python API from sources
goto ie_search_end
:ie_search_end
IF %USE_VENV% == "true" (
echo.
echo Before running the Model Optimizer, please activate virtualenv environment by running "%VENV_DIR%\Scripts\activate.bat"
) ELSE (
echo.
echo [ WARNING ] All Model Optimizer dependencies are installed globally.
echo [ WARNING ] If you want to keep Model Optimizer in separate sandbox
echo [ WARNING ] run install_prerequisites.bat "{caffe|tf|tf2|mxnet|kaldi|onnx}" venv
)
echo *****************************************************************************************
echo Optional: To speed up model conversion process, install protobuf-*.egg located in the
echo "model-optimizer\install_prerequisites" folder or building protobuf library from sources.
@@ -35,6 +35,7 @@ for ((i=1;i <= $#;i++)) {
esac
}
VENV_DIR="$HOME/venv_openvino"
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )"
if [[ -f /etc/centos-release ]]; then
@@ -53,23 +54,8 @@ if [[ $DISTRO == "centos" ]]; then
elif command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
fi
if [ -z "$python_binary" ]; then
sudo -E yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo -E yum install -y python36u python36u-pip
sudo -E pip3.6 install virtualenv
python_binary=python3.6
fi
# latest pip is needed to install tensorflow
sudo -E "$python_binary" -m pip install --upgrade pip
elif [[ $DISTRO == "ubuntu" ]]; then
sudo -E apt update
sudo -E apt -y --no-install-recommends install python3-pip python3-venv
else
python_binary=python3
sudo -E "$python_binary" -m pip install --upgrade pip
elif [[ "$OSTYPE" == "darwin"* ]]; then
python_binary=python3
python3 -m pip install --upgrade pip
fi
install_latest_ov() {
@@ -181,21 +167,21 @@ find_ie_bindings() {
}
if [[ $V_ENV -eq 1 ]]; then
"$python_binary" -m venv "$SCRIPTDIR/../venv${postfix}"
source "$SCRIPTDIR/../venv${postfix}/bin/activate"
venv_python_binary="$SCRIPTDIR/../venv${postfix}/bin/$python_binary"
$venv_python_binary -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt"
"$python_binary" -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
venv_python_binary="$VENV_DIR/bin/$python_binary"
# latest pip is needed to install tensorflow
"$venv_python_binary" -m pip install --upgrade pip
"$venv_python_binary" -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt"
find_ie_bindings "$venv_python_binary" false
echo
echo "Before running the Model Optimizer, please activate virtualenv environment by running \"source ${SCRIPTDIR}/../venv${postfix}/bin/activate\""
echo "Before running the Model Optimizer, please activate virtualenv environment by running \"source $VENV_DIR/bin/activate\""
else
if [[ "$OSTYPE" == "darwin"* ]]; then
python3 -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt"
find_ie_bindings python3 false
else
sudo -E $python_binary -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt"
find_ie_bindings $python_binary true
fi
# latest pip is needed to install tensorflow
"$python_binary" -m pip install --upgrade pip
"$python_binary" -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt"
find_ie_bindings "$python_binary" false
echo
echo "[WARNING] All Model Optimizer dependencies are installed globally."
echo "[WARNING] If you want to keep Model Optimizer in separate sandbox"
echo "[WARNING] run install_prerequisites.sh \"{caffe|tf|tf2|mxnet|kaldi|onnx}\" venv"