# REALTA Maintenance Guide

# Upgrading OS on REALTA

First update everything, it’s great if this works with `sudo apt update`, but more than likely it won’t. Depending on the last time the packages were updated you may need to do a fresh install as many of the packages urls might be out of date. It may also be easier to reinstall the packages after the fact, so it uninstall you can use the following command.

```bash
sudo apt-get purge --auto-remove
```

The two main packages that often cause problems are

1. *libnvidia-container-toolkit*
2. *libnvidia-container1*

Once this roadblock has been lifted the following set of commands will deploy an OS upgrade.

```bash
sudo apt-get update
sudo apt-get upgrade
sudo reboot
sudo apt install update-manager-core
sudo do-release-upgrade
sudo reboot
```

Updates for LTS versions are rolled out step wise. This means that if the machine is on 1.16, it will have to roll through 1.17, 1.18 and so on until the desired version is reached. Between each of these upgrades you will need to run `sudo apt-get update` until no entries appear when `sudo apt list --upgradable` is executed. Repeat the above code block until desired LTS version is released.

#### Re-installing NVIDIA Drivers 

In the cases where the NVIDIA libraries have been uninstalled they will have to be re-installed after the desired LTS version has been deployed.

```bash
sudo ubuntu-drivers autoinstall # automatic 
ubuntu-drivers devices # shows needed drivers 
sudo apt install nvidia-<driver number> 
```

In most cases the first line of code will install the drivers with little issues as long as the GPU is recognized as plugged into the PCI-e slot. Once this install is complete the following commands can be used to check that the GPU is running as expected.

```bash
prime-select query
nvidia-smi # make sure you see an actual gpu when this is run 
```

The GPU diagnostics should be visible after `nvidia-smi` has been executed.

#### Re-calibrating Dockers to use GPU's after OS Upgrade

As most the PSR software on REALTA makes use of the installed the GPU's it need to reinstall the NVIDIA container toolkit.

```bash
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-container-toolkit
```