Last active
February 6, 2018 16:21
-
-
Save fvisin/d90d38c5b85b733327d98e9512a7f0f5 to your computer and use it in GitHub Desktop.
TF install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TF_SOURCE_DIR="`pwd`/tensorflow" | |
WHEEL_DIR="$TF_SOURCE_DIR/tensorflow/wheel/" | |
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/" | |
##### Initialize variables ##### | |
# Define a TMP dir | |
if [[ `hostname -d` == 'iro.umontreal.ca' ]] ; then | |
OUT_BASE="/Tmp/visin/bazel-cache" | |
else | |
OUT_BASE="/tmp/bazel-cache" | |
fi | |
export TEST_TMPDIR=$OUT_BASE # This seems to work! | |
# If on NFS we should move the source on a local disk to compile it | |
if [[ `hostname -d` == 'iro.umontreal.ca' ]] ; then | |
echo "Copying dir to /Tmp" | |
rm -rf /Tmp/visin/tensorflow | |
cp -r $TF_SOURCE_DIR /Tmp/visin/tensorflow | |
cd /Tmp/visin/tensorflow | |
fi | |
read -p "Do you want to configure tensorflow? " -n 1 -r; echo # Move to a new line | |
if [[ "$REPLY" =~ ^[^Nn]$ ]]; then | |
##### Print flags string for user ##### | |
echo -e "\nUse the following flags:" | |
if [[ `hostname` == 'nvidia-robotica' ]] ; then | |
# printf "\tFlags: -march=native -mfma -mfpmath=both -msse4.2\n" | |
printf "\tFlags: -march=native -msse4.2\n" | |
printf "\tCompute capability: 5.2" | |
elif [[ `hostname` == 'fraptop' ]] ; then | |
printf "\tFlags: -march=native -mfpmath=both -msse4.2\n" | |
elif [[ `hostname -d` == 'iro.umontreal.ca' ]] ; then | |
printf "\tFlags: -march=native -mfma -mfpmath=both -msse4.2 -mavx\n" # -mavx2 -mfma | |
elif [[ `hostname` == 'aiteam' ]] ; then | |
printf "\tFlags: -march=native -mfma -mfpmath=both -msse4.2 -mavx -mavx2\n" | |
fi | |
echo -e "\n" | |
##### Configure and compile ##### | |
# Configure | |
(cd $TF_SOURCE_DIR && ./configure --output_base $OUT_BASE) | |
if [ $? -neq 0 ];then | |
echo "Configuration failed!!" | |
exit $? | |
fi | |
fi | |
# Build | |
read -p "Do you want to build tensorflow? " -n 1 -r; echo # Move to a new line | |
if [[ "$REPLY" =~ ^[^Nn]$ ]]; then | |
FLAGS="--config=opt" | |
if [[ `hostname` == 'fraptop' ]] ; then | |
echo "\n*** Compilation without CUDA" | |
elif [[ `hostname -d` == 'iro.umontreal.ca' ]] ; then | |
echo "\n*** Compilation using MILA config" | |
FLAGS="--output_user_root $OUT_BASE $FLAGS --config=cuda" | |
else | |
echo "\n*** Compilation with CUDA" | |
FLAGS=$FLAGS" --config=cuda" | |
fi | |
(cd $TF_SOURCE_DIR && bazel build $FLAGS //tensorflow/tools/pip_package:build_pip_package) || { echo 'Compilation failed' ; exit 1; } | |
fi | |
# Build pip | |
read -p "Do you want to build the pip package? " -n 1 -r; echo # Move to a new line | |
if [[ "$REPLY" =~ ^[^Nn]$ ]]; then | |
echo -e "\nBuilding pip package" | |
(cd $TF_SOURCE_DIR && bazel-bin/tensorflow/tools/pip_package/build_pip_package $WHEEL_DIR) || { echo 'Pip compilation failed' ; exit 1; } | |
fi | |
# Install pip | |
read -p "Do you want to install tensorflow? " -n 1 -r; echo # Move to a new line | |
if [[ "$REPLY" =~ ^[^Nn]$ ]]; then | |
LATEST_WHEEL=`find $WHEEL_DIR -type f -printf '%T@ %p\n' | sort -n | head -1 | cut -f2- -d" "` | |
read -p "Do you want to install it locally? " -n 1 -r; echo # Move to a new line | |
if [[ "$REPLY" =~ ^[Yy]$ ]]; then | |
echo -e "\nInstalling pip package locally" | |
pip install --user -U $LATEST_WHEEL | |
if [[ `hostname -d` == 'iro.umontreal.ca' ]] ; then | |
pip uninstall numpy | |
exit $? | |
fi | |
else | |
echo -e "\nInstalling pip package globally" | |
if [ $EUID != 0 ]; then | |
sudo pip install -U $LATEST_WHEEL | |
exit $? | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment