Skip to content

Commit

Permalink
[Examples] Add docker compose example to run multiple containers (#2745)
Browse files Browse the repository at this point in the history
* Add docker compose example

* newline

* Add repo setup for AWS

* Change CUDA to 11.5 for azure compat

* Add device_id

* typo
  • Loading branch information
romilbhardwaj authored Nov 6, 2023
1 parent d80c47b commit 5a35ab6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/docker/compose/compose_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Minimal example using docker compose to run multiple containers
#
# Syncs the docker-compose.yml in the current workdir to the remote cluster and
# runs docker compose up.
#
# Usage:
# sky launch -c myclus compose_example.yaml
# sky down myclus

resources:
accelerators: T4:2

workdir: .

setup: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-compose-plugin
run: |
docker compose -f docker-compose.yml up
24 changes: 24 additions & 0 deletions examples/docker/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
gpu-app1:
image: nvidia/cuda:11.5.2-runtime-ubuntu20.04
command: nvidia-smi # To keep running in a loop, add -l 1
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['0']
capabilities: [gpu]

gpu-app2:
image: nvidia/cuda:11.5.2-runtime-ubuntu20.04
command: nvidia-smi
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['1'] # Allocates GPU ID 1 to this container. Inside the container, this will be visible as device id 0
capabilities: [gpu]

0 comments on commit 5a35ab6

Please sign in to comment.