Ubuntu Server Preparation

To prepare a server on Ubuntu for the FindFace Multi deployment, follow the instructions below minding the sequence.

Note

For other platforms, please refer to the following resources:

In this section:

GPU: Install NVIDIA Drivers

The first step of the server preparation is the NVIDIA driver installation. It’s applicable only for the GPU configuration. Go straight to the Docker installation if your configuration is CPU-accelerated.

With the GPU-accelerated FindFace Multi, you’ll need the NVIDIA driver version 530 or above. Add the NVIDIA repository and install an applicable driver from it, or download a relevant .run installer from NVIDIA Driver Downloads.

Warning

It is not recommended using a .run installer from NVIDIA as its drivers may conflict with the drivers installed via packages.

To install the 530 driver from a repository, do the following:

  1. Install the repository signature key:

    arch=$(uname -m); version=$(. /etc/os-release; echo $ID$VERSION_ID | sed -r 's/\.//g'); sudo bash -c \
    "sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$ID$version/$arch/3bf863cc.pub \
    && apt update"
    
  2. Install aptitude and execute the following command:

    sudo aptitude install nvidia-driver-530
    

Install Docker Products

Docker products must be installed on both CPU and GPU servers. Do the following:

  1. Update the apt package index and install packages to allow apt to use a repository over HTTPS.

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

    Tip

    You may receive the following errors when running sudo apt-get install \:

    E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
    E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
    

    There are two ways to resolve them:

    1. Forcibly terminate all the apt-get processes currently running in the system.

      sudo killall apt apt-get
      
    2. If the previous command didn’t help, run the set of commands below. It’s fine if some of the to-be-deleted directories do not exist — just keep going.

      sudo rm /var/lib/apt/lists/lock
      sudo rm /var/cache/apt/archives/lock
      sudo rm /var/lib/dpkg/lock
      sudo rm /var/lib/dpkg/lock-frontend
      sudo dpkg --configure -a
      
  2. Add the Docker’s official GPG key (GNU Privacy Guard key) to the host.

    sudo mkdir -m 0755 -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    
  3. Set up the Docker repository.

    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  4. Update the apt package index one more time.

    sudo apt-get update
    

    Tip

    If you have received a GPG error when running this command, try granting read permission for the Docker public key file before updating the package index.

    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    sudo apt-get update
    
  5. Install the latest versions of Docker products.

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
    
  6. Check whether the Docker installation was a success. The following command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

    sudo docker run hello-world
    
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    2db29710123e: Pull complete
    Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
       (amd64)
    3. The Docker daemon created a new container from that image which runs the
       executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
       to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/
    
    For more examples and ideas, visit:
    https://docs.docker.com/get-started/
    
  7. Install docker-compose.

    sudo curl -SL https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
    
  8. Perform the Docker Engine post-installation procedures to ease your future work with Docker and FindFace Multi containers. Once you can manage Docker as a non-root user, you don’t have to apply sudo in the commands related to Docker.

    sudo groupadd docker
    sudo usermod -aG docker $USER
    newgrp docker
    

GPU: Install NVIDIA Container Runtime

To deploy containerized GPU-accelerated FindFace Multi, you need NVIDIA Container Runtime. We recommend installing NVIDIA Container Toolkit that includes this runtime. Do the following:

  1. Specify the repository and install NVIDIA Container Toolkit from it by executing the following commands.

    distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
          && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
          && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
                sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
                sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
    sudo apt-get update
    sudo apt-get install -y nvidia-container-toolkit
    sudo nvidia-ctk runtime configure --runtime=docker
    sudo systemctl restart docker
    
  2. Configure the Docker network to use the NVIDIA Container Runtime installed along with NVIDIA Container Toolkit.

    sudo su
    BIP=10.$((RANDOM % 256)).$((RANDOM % 256)).1
    cat > /etc/docker/daemon.json <<EOF
    {
        "bip": "$BIP/24",
        "fixed-cidr": "$BIP/24",
        "runtimes": {
             "nvidia": {
                 "path": "nvidia-container-runtime",
                 "runtimeArgs": []
             }
        },
        "default-runtime": "nvidia"
    }
    EOF
    
  3. Restart Docker.

    systemctl restart docker
    

Now you are all set to install FindFace Multi. Refer to the following sections: