3 # Copyright (c) 2018 Intel Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 echo "Error on or near line $1: $2; exiting with status ${code}"
22 echo "Error on or near line $1; exiting with status ${code}"
26 trap 'error ${LINENO}' ERR
31 for ((i=1;i <= $#;i++)) {
33 caffe|tf|mxnet|kaldi|onnx)
40 if [[ "$1" != "" ]]; then
41 echo "\""${!i}"\" is unsupported parameter"
42 echo $"Usage: $0 {caffe|tf|mxnet|kaldi|onnx} {venv}"
49 SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
51 if [[ -f /etc/centos-release ]]; then
53 elif [[ -f /etc/lsb-release ]]; then
57 if [[ $DISTRO == "centos" ]]; then
58 if command -v python3.5 >/dev/null 2>&1; then
59 python_binary=python3.5
61 if command -v python3.6 >/dev/null 2>&1; then
62 python_binary=python3.6
64 if [ -z "$python_binary" ]; then
65 sudo -E yum install -y https://centos7.iuscommunity.org/ius-release.rpm
66 #sudo -E yum install -y python36u easy_install python36u-pip
67 sudo -E yum install -y python36u python36u-pip
68 sudo -E pip3.6 install virtualenv
69 python_binary=python3.6
71 elif [[ $DISTRO == "ubuntu" ]]; then
73 sudo -E apt -y install python3-pip python3-venv libgfortran3
78 if [[ $V_ENV -eq 1 ]]; then
79 $python_binary -m venv $SCRIPTDIR/../venv
80 source $SCRIPTDIR/../venv/bin/activate
81 $SCRIPTDIR/../venv/bin/$python_binary -m pip install -r $SCRIPTDIR/../requirements${postfix}.txt
83 echo "Before running the Model Optimizer, please activate virtualenv environment by running \"source ${SCRIPTDIR}/../venv/bin/activate\""
85 sudo -E $python_binary -m pip install -r $SCRIPTDIR/../requirements${postfix}.txt
86 echo [WARNING] All Model Optimizer dependencies are installed globally.
87 echo [WARNING] If you want to keep Model Optimizer in separate sandbox
88 echo [WARNING] run install_prerequisites.sh venv "{caffe|tf|mxnet|kaldi|onnx}"