Skip to content

Instantly share code, notes, and snippets.

@benfoley
Last active November 16, 2022 11:04
Show Gist options
  • Save benfoley/b155dfa08e3bbe0fa43ffe84efaf8474 to your computer and use it in GitHub Desktop.
Save benfoley/b155dfa08e3bbe0fa43ffe84efaf8474 to your computer and use it in GitHub Desktop.
# GPU startup script v0.6.3
# Check if this has been done before. Skip driver installation if so, just run Elpis
if [[ -f /etc/startup_installed ]];
then
sudo chmod 666 /var/run/docker.sock
# Run Elpis (non-interactive so that Elpis starts automatically)
docker run -d --rm --name elpis --gpus all -p 80:5001/tcp -p 6006:6006/tcp coedl/elpis:latest
exit 0;
fi
# Otherwise, install all the things.. then run Elpis
# Install CUDA
sudo apt install linux-headers-$(uname -r)
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt update
sudo apt -y install cuda
# Install NVIDIA Container Toolkit
curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
sudo usermod -aG docker $USER
sudo chown $USER /var/run/docker.sock
sudo chmod 666 /var/run/docker.sock
# Handy little app to check NVIDIA GPUs stats
sudo apt -y install nvtop
# Get elpis
cd ~
git clone https://github.com/CoEDL/elpis.git
# Will make it easier to copy model files etc out of the container
mkdir state
# Make a file which can be detected on next startup and thus skip doing this every time
touch /etc/startup_installed
echo "done"
# Download and run Elpis (non-interactive so that Elpis starts automatically)
docker run -d --rm --name elpis --gpus all -p 80:5001/tcp -p 6006:6006/tcp coedl/elpis:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment