Last active
February 21, 2018 01:30
-
-
Save arundasan91/f5224ea441a428c70192b3f539e9c164 to your computer and use it in GitHub Desktop.
This bash script will create OpenStack `openrc` file for the current tenant, source it, download required files from OpenStack Swift Object Storage and then runs the scripts to install TensorFlow 1.3, OpenCV from source and some other user defined packages.
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
#!/usr/bin/env bash | |
# OpenRC extraction | |
function extract_json_key { | |
RESULT=$(echo "$2" | sed "s/.*$1\": \"//g" | sed 's/".*//g') | |
echo "$RESULT" | |
} | |
JSON_VENDOR_DATA=$(curl -s http://169.254.169.254/openstack/latest/vendor_data.json) | |
SITE=$(extract_json_key "site" "$JSON_VENDOR_DATA") | |
if [ "$SITE" != "tacc" ] && [ "$SITE" != "uc" ]; then | |
# The current instance is apparently not a baremetal node. | |
echo "ERROR: Could not understand which site you are using, please be sure that you run the script inside a baremetal instance!" | |
exit 1 | |
fi | |
PROJECT_ID=$(extract_json_key "project_id" "$JSON_VENDOR_DATA") | |
cat > ~/.openrc <<-EOM | |
#!/bin/bash | |
export OS_AUTH_URL=https://chi.$SITE.chameleoncloud.org:5000/v2.0 | |
export OS_TENANT_ID=$PROJECT_ID | |
export OS_REGION_NAME="regionOne" | |
echo "Please enter your Chameleon Username: " | |
read -r OS_USERNAME_INPUT | |
export OS_USERNAME=\$OS_USERNAME_INPUT | |
echo "Please enter your Chameleon Password: " | |
read -sr OS_PASSWORD_INPUT | |
export OS_PASSWORD=\$OS_PASSWORD_INPUT | |
EOM | |
source ~/.openrc | |
echo "Downloading CUDNN and setting up libraries" | |
swift download CUDNN6-for-CUDA8 -D /home/$USER/packages/ | |
sudo chmod a+r /usr/local/cuda/include/* | |
sudo tar -xzf /home/$USER/packages/cudnn-8.0-linux-x64-v6.0.tgz -C /usr/local | |
swift download Ubuntu-Scripts | |
# Add PATH variables of libraries to ~/.bashrc file. | |
cat >> ~/.bashrc <<- EOM | |
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64" | |
export CUDA_HOME=/usr/local/cuda | |
EOM | |
source ~/.bashrc | |
sudo chmod u+x scripts/cudnn6_tf1.3.sh | |
sudo chmod u+x scripts/opencv3.3_from_source.sh | |
sudo chmod u+x scripts/X11_setup.sh | |
sudo chmod u+x scripts/basic_packages.sh | |
echo "Starting to build TensorFlow" | |
bash scripts/cudnn6_tf1.3.sh | |
echo "Starting to build OpenCV" | |
bash scripts/opencv3.3_from_source.sh | |
echo "Starting to configure X11" | |
sudo bash scripts/X11_setup.sh | |
echo "Starting to install additional libraries" | |
bash scripts/basic_packages.sh | |
echo "Installing Docker CE and NVIDIA-Docker" | |
bash scripts/install_docker.sh | |
echo "Reinstalling NVIDIA Driver" | |
bash scripts/reinstall_nvidia.sh | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment