#!/bin/bash
# shellcheck disable=SC2090,SC2086,SC2089,SC1091
## This script aims to setup the OS for a (cloud) VM
## starting from the "Lambda Stack 22.04/24.04" images support x86-64, arm64 and Python 3.10/3.12 respectively.
## Lambda Stack: The default image used on most ODC instances.
## Includes: NVIDIA driver, CUDA toolkit, OFED, cuDNN, NCCL, Lambda Stack Python packages (PyTorch, TensorFlow, JAX), Docker, JupyterLab
## Use if: You want something that "just works" and don't need deep configurability.

#! Update and upgrade package manager
sudo apt-get update
#! Installing the essentials
sudo apt-get install -y build-essential zlib1g-dev libedit-dev \
	libssl-dev liblzma-dev libffi-dev libbz2-dev \
	libreadline-dev libsqlite3-dev bc clang

#! Set GPU persistence mode
sudo nvidia-smi -pm 1

#! Install `UV`
UV_VER_OUTPUT=$(uv --version)
if [[ $UV_VER_OUTPUT == *"uv "* ]]; then
	echo "UV is already installed."
else
	#! Getting `UV`
	curl -LsSf https://astral.sh/uv/install.sh | sh
fi

#! Upgrade pip
sudo pip install --upgrade pip

#! Monitoring utilities and cmake
sudo apt -y install bpytop
sudo pip install nvitop cmake
