Skip to content

Instantly share code, notes, and snippets.

@Deadlyelder
Last active January 3, 2018 20:53
Show Gist options
  • Save Deadlyelder/ef5e3448d0d4b583784be2fc6d6714d1 to your computer and use it in GitHub Desktop.
Save Deadlyelder/ef5e3448d0d4b583784be2fc6d6714d1 to your computer and use it in GitHub Desktop.
install tensorflow via virtualenv
#!/bin/bash
TF="tensorflow"
TF_VER="1.4.0"
TF_DIR="$HOME"
ENV_NAME="tf-env"
GREEN="\033[0;32m"
RESET="\033[0m"
# create new env for tensorflow
new_tf_env () {
cd ${TF_DIR}
python -m virtualenv ${ENV_NAME}
source ${ENV_NAME}/bin/activate
pip install ${TF}==${TF_VER}
deactivate
}
# verify the installation of tensorflow
test_tf () {
cd ${TF_DIR}
wget https://gist.githubusercontent.com/Deadlyelder/7ae29ec4e79edded9b6ac9dc4b5c3927/raw/c0c5c72e65a1d640b959e39aa7b97a831fde3923/tensorflow_test.py
source ${ENV_NAME}/bin/activate
python tensorflow_test.py
deactivate
rm tensorflow_test.py
}
# create new env for tensorflow
if [ ! -f "${TF_DIR}/${ENV_NAME}/bin/activate" ]; then
rm -rf "${TF_DIR}/${ENV_NAME}"
new_tf_env
test_tf
fi
echo "Done."
echo -e "Activate the environment by ${GREEN}source ${TF_DIR}/${ENV_NAME}/bin/activate${RESET}."
echo -e "Deactivate the environment by ${GREEN}deactivate${RESET}."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment