Skip to content

Ubuntu Docker

romatsypin edited this page Dec 15, 2021 · 10 revisions

Preinstallations

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
sudo apt-get dist-upgrade

Installing Docker

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

If the installation went well, sudo docker run hello-world should pull the test image and run it.

Enabling GPU via Nvidia-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 docker run --rm --gpus all nvidia/cuda:11.4.2-base-ubuntu20.04 nvidia-smi

In this case, the GPU is enabled via Cuda 11. It might be incompatible with future versions of python and tensorflow.

Cloning Repository

Before cloning repository, you need to obtain a Personal Access Token, which will be used instead of the password in Terminal. In GitHub, go to Settings-> Developer Settings -> Personal access tokens -> Generate new token. After granting permissions, do not forget to write down the token. Once you have retrieved the token, you will need to provide GitHub with credentials.

git config --global user.name "Your GitHub Username"
git config --global user.email "Your GitHub Email"

If you do not want to set the global credentials, you can also navigate to your repository of interest and run the commands without the --global flag.

git clone https://[email protected]/hamk-uas/drone-image-analysis

Use the token when the terminal asks for the password.

Pulling and Running the Docker Image

sudo docker pull roamts/customflow:latest-windows
sudo docker run -it --gpus all --rm -v <Path To The Repository>:/tf/ -p 8888:8888 -p 6006:6006 customflow:latest

To quickly run the jupyter with the aforementioned settings, you can use sh run-jupyter inside the directory.

Notice that this image is custom, and thus it may not be the latest or not contain additional libraries. This may affect the training performance and lack features in the future. To replicate the creation of custom image and installation of additional pip libraries, click here.