Skip to content

Instantly share code, notes, and snippets.

@sugarme
Last active April 11, 2021 11:47
Show Gist options
  • Save sugarme/e2c2af2ca350e49f71f075a0972f5a15 to your computer and use it in GitHub Desktop.
Save sugarme/e2c2af2ca350e49f71f075a0972f5a15 to your computer and use it in GitHub Desktop.
Basic colab setup for Go deep learning
#!/bin/bash
# Upgrade cmake and g++:
#=======================
apt remove --purge --auto-remove cmake
rm -rf /usr/lib/x86_64-linux-gnu/cmake
rm -rf /usr/local/bin/cmake
# cmake: ref https://apt.kitware.com/
apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
apt-get update
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic-rc main'
apt-get update
apt-get install kitware-archive-keyring
rm /etc/apt/trusted.gpg.d/kitware.gpg
apt-get install cmake
apt-get install g++-8 -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
# Install Go:
#============
wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
# Install libtorch GPU
#======================
wget -q --show-progress --progress=bar:force:noscroll -O libtorch.zip https://download.pytorch.org/libtorch/cu110/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu110.zip
unzip libtorch.zip -d /usr/local/lib
rm libtorch.zip
ldconfig
export GOTCH_LIBTORCH="/usr/local/lib/libtorch"
export LIBTORCH="/usr/local/lib/libtorch"
export LIBRARY_PATH="$LIBRARY_PATH:$GOTCH_LIBTORCH/lib"
export CPATH="$CPATH:$GOTCH_LIBTORCH/lib:$GOTCH_LIBTORCH/include:$GOTCH_LIBTORCH/include/torch/csrc/api/include"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GOTCH_LIBTORCH/lib:/usr/local/cuda-11.2/compat:/usr/local/cuda-11.2/lib64:/usr/lib"
# Install Gotch
#==============
GOTCH_VERSION="${GOTCH_VER:-v0.3.9-rc1}"
GOTCH_PATH="$GOPATH/pkg/mod/github.com/sugarme/gotch@$GOTCH_VERSION"
echo "GOPATH:'$GOPATH'"
echo "GOTCH_VERSION: '$GOTCH_VERSION'"
cwd=$(pwd)
sudo rm -rf /tmp/gotch-test
mkdir /tmp/gotch-test
cd /tmp/gotch-test
go mod init "github.com/sugarme/gotch-test"
go get "github.com/sugarme/gotch@$GOTCH_VERSION"
rm -rf /tmp/gotch-test
cd $cwd
# htop, Tmux, vim:
#=================
apt install htop
apt install tmux
export TERM=screen-256color # fixed tmux changes Vim color theme
# Install vim 8.2
add-apt-repository ppa:jonathonf/vim -y
apt update
apt install vim
# Vim plugins and theme
git clone https://github.com/sugarme/lvim.git
mv lvim .vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
# Compile YCM
cd ~/.vim/bundle/YouCompleteMe
./install.py --all
cd $HOME
# Run Tmux:
#==========
tmux new-session -d -x "$(tput cols)" -y "$(tput lines)"
tmux split-window -h -p 35 'watch -n0.1 nvidia-smi'
tmux split-window -v -p 50 'htop'
tmux split-window -v
tmux -2 attach-session -d
echo "export TERM=screen-256color"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment