I tried different installation methods via
curl
which failed because of a non existing URLapt-get
which worked but the installed version does not GPU accesspip
which worked and the installed version does GPU access
Below the tried methods in detail.
Following the instructions from https://docs.docker.com/compose/install/ resulted in the following error when trying to run docker-compose
afterwards.
# instructions from link above
sudo curl -L "https://github.com/docker/compose/releases/download/v1.29.2/docker-compose-$(uname -s)-$(uname -m)" -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
# trying to run docker-compose afterwars
docker-compose
# resulted in
/usr/local/bin/docker-compose: line 1: Not: command not found
The URL that gets created in the first line of the installation instructions does not exist, which can be checked as follows.
# URL from the first command of the installation instructions
url_to_check="https://github.com/docker/compose/releases/download/v1.29.2/docker-compose-$(uname -s)-$(uname -m)"
# checking if URL exits
echo $(curl -s --head -w %{http_code} $url_to_check -o /dev/null)
# results in
404
The installation succeeded processing the following.
# install docker-compose using apt-get
sudo apt-get update
sudo apt-get install docker-compose
# 2022-01-15 installed got version:
# docker-compose version 1.25.0, build unknown
The installed version is unsufficient for GPU support, which requires v2.3 or v1.28.+, referring to https://docs.docker.com/compose/gpu-support/
# python
# installing python3-pip
sudo apt-get update
sudo apt-get install python3-pip
# or just update pip in case it is already installed
sudo pip install --upgrade pip
# installing docker-compose
sudo pip install docker-compose~=1.29.2
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# installed via apt-get
sudo apt-get remove docker-compose
# installed via curl
sudo rm /usr/local/bin/docker-compose
sudo rm /usr/bin/docker-compose
# installed via pip (without venv)
sudo pip uninstall docker-compose
sudo rm /usr/bin/docker-compose
# assigning a number of GPUs to the container
version: "3.8"
services:
test_nvidia_smi_count:
image: nvidia/cuda:11.0-base
command: nvidia-smi
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
docker-compose run test_nvidia_smi_count
# results in:
Creating project_test_nvidia_smi_count_run ... done
Sun Jan 16 17:52:22 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.29.05 Driver Version: 495.29.05 CUDA Version: 11.5 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA TITAN RTX On | 00000000:65:00.0 Off | N/A |
| 41% 28C P8 4W / 280W | 97MiB / 24219MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
# assigning specific GPU to container by its index
version: "3.8"
services:
test_nvidia_smi_device_ids:
image: nvidia/cuda:11.0-base
command: nvidia-smi
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['0']
capabilities: [gpu]
docker-compose run test_nvidia_smi_device_ids
# results in:
Creating project_test_nvidia_smi_device_ids_run ... done
Sun Jan 16 17:51:42 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.29.05 Driver Version: 495.29.05 CUDA Version: 11.5 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA TITAN RTX On | 00000000:65:00.0 Off | N/A |
| 41% 28C P8 3W / 280W | 97MiB / 24219MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|