From bec7e42544a8a5d5a088e5f373011823bbf969cc Mon Sep 17 00:00:00 2001 From: Gabriel Date: Thu, 7 Nov 2019 21:41:38 -0300 Subject: [PATCH 1/3] updated install scripts and conf to allow user input of virtualenv path --- install-utilities.sh | 1 + install.sh | 5 +++-- ncsdk.conf | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/install-utilities.sh b/install-utilities.sh index 3e8ada8..3ac371d 100755 --- a/install-utilities.sh +++ b/install-utilities.sh @@ -105,6 +105,7 @@ function read_ncsdk_config() INSTALL_TOOLKIT=yes PIP_SYSTEM_INSTALL=yes USE_VIRTUALENV=no + VIRTUALENV_DIR=${INSTALL_DIR}/virtualenv-python ### set # jobs to make simultaneously, MAKE_NJOBS, defaults to 1. diff --git a/install.sh b/install.sh index a1d2e35..0425fae 100755 --- a/install.sh +++ b/install.sh @@ -104,6 +104,7 @@ function print_ncsdk_config() echo "PIP_SYSTEM_INSTALL - Globally install pip packages via sudo -H" echo "VERBOSE - Flag to enable more verbose installation" echo "USE_VIRTUALENV - Flag to enable python virtualenv" + echo "VIRTUALENV_DIR - Virtual environment directory" echo "MAKE_NJOBS - Number of processes to use for parallel build (i.e. make -j MAKE_NJOBS)" echo "" echo "INSTALL_DIR=${INSTALL_DIR}" @@ -115,6 +116,7 @@ function print_ncsdk_config() echo "PIP_SYSTEM_INSTALL=${PIP_SYSTEM_INSTALL}" echo "VERBOSE=${VERBOSE}" echo "USE_VIRTUALENV=${USE_VIRTUALENV}" + echo "VIRTUALENV_DIR=${VIRTUALENV_DIR}" echo "MAKE_NJOBS=${MAKE_NJOBS}" echo "" } @@ -314,7 +316,6 @@ function setup_virtualenv() ${SUDO_PREFIX} apt-get $APT_QUIET install python-virtualenv -y echo "" - VIRTUALENV_DIR=${INSTALL_DIR}/virtualenv-python # if virtualenv dir exists, try to activate it if [ -d ${VIRTUALENV_DIR} ] ; then RC=0 @@ -329,7 +330,7 @@ function setup_virtualenv() exit 1 echo "" else - echo "virtualenv ${INSTALL_DIR}/virtualenv-python exists, and successfully activated it" + echo "virtualenv ${VIRTUALENV_DIR} exists, and successfully activated it" fi else # Create new virtualenv and activate it diff --git a/ncsdk.conf b/ncsdk.conf index c5b7aed..4d45400 100644 --- a/ncsdk.conf +++ b/ncsdk.conf @@ -7,4 +7,5 @@ INSTALL_TOOLKIT=yes PIP_SYSTEM_INSTALL=yes VERBOSE=yes USE_VIRTUALENV=no +VIRTUALENV_DIR=/opt/movidius/virtualenv-python #MAKE_NJOBS=1 From df49b01f81b012cf8ea119ed84048c2010c977a1 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Thu, 7 Nov 2019 23:45:00 -0300 Subject: [PATCH 2/3] updated install and uninstall scripts to affect only virtualenv if option is enabled --- install.sh | 11 ++++++++--- uninstall.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 0425fae..5901de1 100755 --- a/install.sh +++ b/install.sh @@ -337,6 +337,7 @@ function setup_virtualenv() echo "Creating new virtualenv in ${VIRTUALENV_DIR}" ${SUDO_PREFIX} mkdir -p ${VIRTUALENV_DIR} ${SUDO_PREFIX} virtualenv --system-site-packages -p python3 ${VIRTUALENV_DIR} + ${SUDO_PREFIX} chown -R $USER:$USER ${VIRTUALENV_DIR} # disable trapping for unset variables due to activate script set +u RC=0 @@ -741,9 +742,13 @@ function install_api() # Install python API $SUDO_PREFIX cp ${FROM_DIR}/api/python/mvnc/mvncapi.py $SDK_DIR/api/python/mvnc $SUDO_PREFIX cp ${FROM_DIR}/api/python/mvnc/__init__.py $SDK_DIR/api/python/mvnc - exec_and_search_errors "$PIP_PREFIX pip3 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" - exec_and_search_errors "$PIP_PREFIX pip2 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" - echo "NCS Python API has been installed in $INSTALL_DIR, and PYTHONPATH environment variable updated" + if [ "${USE_VIRTUALENV}" == 'yes' ]; then + exec_and_search_errors "$PIP_PREFIX pip install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + else + exec_and_search_errors "$PIP_PREFIX pip3 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + exec_and_search_errors "$PIP_PREFIX pip2 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + fi + echo "NCS Python API has been installed in $INSTALL_DIR, and PYTHONPATH environment variable updated" } diff --git a/uninstall.sh b/uninstall.sh index 0336072..b99e9e3 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -57,6 +57,30 @@ function remove_install_dir() } +function initialize_virtualenv() +{ + # if virtualenv dir exists, try to activate it + if [ -d ${VIRTUALENV_DIR} ] ; then + RC=0 + # disable trapping for unset variables due to activate script + set +u + source ${VIRTUALENV_DIR}/bin/activate || RC=$? + set -u + if [ ${RC} -ne 0 ] ; then + echo "source ${VIRTUALENV_DIR}/bin/activate gave an error=${RC}" + echo "You need to investigate: 1) Either figure out why virtualenv is not activating correctly or" + echo " 2) edit ncsdk.conf to set USE_VIRTUALENV=no to disable virtualenv. Will exit" + exit 1 + echo "" + else + echo "virtualenv ${VIRTUALENV_DIR} exists, and successfully activated it" + fi + else + echo "Supplied virtualenv dir does not exist." + fi +} + + # main - this is the main function that runs the uninstall function main() { @@ -76,6 +100,9 @@ function main() ### function is in install-utilities.sh find_previous_install + + # Optionally use python virtualenv, USE_VIRTUALENV set in ncsdk.conf + [ "${USE_VIRTUALENV}" == 'yes' ] && initialize_virtualenv ### remove prev installation. Function is in install-utilities.sh remove_previous_install From 09400f5169aa7d3ac53e8f76f835bbdc1d78d9a5 Mon Sep 17 00:00:00 2001 From: Gabriel Gayoso Date: Thu, 28 Nov 2019 13:02:08 -0300 Subject: [PATCH 3/3] allow 1804 install and change install defaults --- install.sh | 2 +- ncsdk.conf | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 5901de1..675cf1e 100755 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ function check_supported_os() VERSION="$(lsb_release -r 2>/dev/null | awk '{ print $2 }' | sed 's/[.]//')" OS_DISTRO="${DISTRO:-INVALID}" OS_VERSION="${VERSION:-255}" - if [ "${OS_DISTRO,,}" = "ubuntu" ] && [ ${OS_VERSION} = 1604 ]; then + if [ "${OS_DISTRO,,}" = "ubuntu" ] && [[ ${OS_VERSION} = 1604 || ${OS_VERSION} = 1804 ]]; then # Require 64-bit Ubuntu OS HARDWARE_PLATFORM=$(uname -i) if [ "${HARDWARE_PLATFORM}" != "x86_64" ] ; then diff --git a/ncsdk.conf b/ncsdk.conf index 4d45400..1225cd4 100644 --- a/ncsdk.conf +++ b/ncsdk.conf @@ -1,10 +1,10 @@ INSTALL_DIR=/opt/movidius -INSTALL_CAFFE=yes +INSTALL_CAFFE=no CAFFE_FLAVOR=ssd CAFFE_USE_CUDA=no -INSTALL_TENSORFLOW=yes -INSTALL_TOOLKIT=yes -PIP_SYSTEM_INSTALL=yes +INSTALL_TENSORFLOW=no +INSTALL_TOOLKIT=no +PIP_SYSTEM_INSTALL=no VERBOSE=yes USE_VIRTUALENV=no VIRTUALENV_DIR=/opt/movidius/virtualenv-python