Last active
September 14, 2020 23:39
-
-
Save UkiDLucas/efff77cac579577056c2ab3d5f702520 to your computer and use it in GitHub Desktop.
Colab: running Julia 1.4.2
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
%%shell | |
set -e | |
# RUN as a Jupyter/Python cell. | |
#---------------------------------------------------# | |
JULIA_VERSION="1.4.2" # any version ≥ 0.7.0 | |
JULIA_PACKAGES="IJulia BenchmarkTools PyCall PyPlot" | |
JULIA_PACKAGES_IF_GPU="CUDA" | |
JULIA_NUM_THREADS=4 | |
#---------------------------------------------------# | |
if [ -n "$COLAB_GPU" ] && [ -z `which julia` ]; then | |
# Install Julia | |
JULIA_VER=`cut -d '.' -f -2 <<< "$JULIA_VERSION"` | |
echo "Installing Julia $JULIA_VERSION on the current Colab Runtime..." | |
BASE_URL="https://julialang-s3.julialang.org/bin/linux/x64" | |
URL="$BASE_URL/$JULIA_VER/julia-$JULIA_VERSION-linux-x86_64.tar.gz" | |
wget -nv $URL -O /tmp/julia.tar.gz # -nv means "not verbose" | |
tar -x -f /tmp/julia.tar.gz -C /usr/local --strip-components 1 | |
rm /tmp/julia.tar.gz | |
# Install Packages | |
if [ "$COLAB_GPU" = "1" ]; then | |
JULIA_PACKAGES="$JULIA_PACKAGES $JULIA_PACKAGES_IF_GPU" | |
fi | |
for PKG in `echo $JULIA_PACKAGES`; do | |
echo "Installing Julia package $PKG..." | |
julia -e 'using Pkg; pkg"add '$PKG'; precompile;"' | |
done | |
# Install kernel and rename it to "julia" | |
echo "Installing IJulia kernel..." | |
julia -e 'using IJulia; IJulia.installkernel("julia", env=Dict( | |
"JULIA_NUM_THREADS"=>"'"$JULIA_NUM_THREADS"'"))' | |
KERNEL_DIR=`julia -e "using IJulia; print(IJulia.kerneldir())"` | |
KERNEL_NAME=`ls -d "$KERNEL_DIR"/julia*` | |
mv -f $KERNEL_NAME "$KERNEL_DIR"/julia | |
echo '' | |
echo "Successfully installed `julia -v`!" | |
echo "Please reload this page (press Ctrl+R, ⌘+R, or the F5 key) then" | |
echo "jump to the 'Checking the Installation' section." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment