Last active
September 23, 2016 09:18
-
-
Save dhwajraj/77f1ff8c876ad315b5ed6a524dea3135 to your computer and use it in GitHub Desktop.
boot script for installing Java8 and tensorflow when launching a spark EMR cluster.
This file contains 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
# Check java version | |
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') | |
if [ "$JAVA_VER" -lt 18 ] | |
then | |
# Figure out how many versions of Java and javac we currently have | |
NR_OF_JRE_OPTIONS=$(echo 0 | alternatives --config java 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1) | |
NR_OF_SDK_OPTIONS=$(echo 0 | alternatives --config javac 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1) | |
# Silent install javac (includes jre) | |
sudo yum -y install java-1.8.0-devel | |
echo "Found $NR_OF_JRE_OPTIONS existing versions of java. Adding new version." | |
echo "Found $NR_OF_SDK_OPTIONS existing versions of javac. Adding new version." | |
# Make java 8 the default | |
echo $(($NR_OF_JRE_OPTIONS + 1)) | sudo alternatives --config java | |
echo $(($NR_OF_SDK_OPTIONS + 1)) | sudo alternatives --config javac | |
# Fix wrong links | |
sudo rm /etc/alternatives/java_sdk_openjdk;sudo ln -s /usr/lib/jvm/java-1.8.0-openjdk.x86_64 /etc/alternatives/java_sdk_openjdk | |
sudo rm /etc/alternatives/java_sdk_openjdk_exports;sudo ln -s /usr/lib/jvm-exports/java-1.8.0-openjdk.x86_64 /etc/alternatives/java_sdk_openjdk_exports | |
fi | |
# Check java version again | |
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') | |
echo "" | |
echo "Java version is $JAVA_VER!" | |
echo "JAVA_HOME: $JAVA_HOME" | |
echo "JRE_HOME: $JRE_HOME" | |
echo "PATH: $PATH" | |
aws s3 sync s3://mycode /mnt/. & | |
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl & | |
sudo pip install py4j==0.9 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment