Skip to content

Commit

Permalink
fix: update docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens authored Aug 9, 2024
2 parents 42aeb55 + 3261705 commit 64ca607
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
17 changes: 16 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
services:
vllm-cpu-env:
image: ghcr.io/socialgouv/docker/vllm-cpu-env:latest
image: vllm/vllm-openai:latest
environment:
HUGGING_FACE_HUB_TOKEN: "${HUGGING_FACE_HUB_TOKEN}"
command:
- "--model=mistralai/Mistral-7B-v0.1"
- "--tensor-parallel-size=4"
- "--dtype=half" # https://github.com/vllm-project/vllm/issues/1157
expose:
- "8000"
labels:
Expand All @@ -9,6 +15,15 @@ services:
- "traefik.http.routers.vllm-cpu-env.tls.certresolver=myresolver"
- "traefik.http.middlewares.main-auth.basicauth.users=${CREDENTIALS}"
- "traefik.http.routers.vllm-cpu-env.middlewares=main-auth@docker"
runtime: nvidia # Set the desired runtime for GPU support
ipc: host # Set the IPC namespace to host
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]

reverse-proxy:
image: traefik:v2.4
Expand Down
14 changes: 12 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def getRequiredEnv(key):
sys.exit(1)
return value

def indentString(input_string, indent_level=4):
indent = ' ' * indent_level
return '\n'.join(indent + line for line in input_string.splitlines())

if len(sys.argv) != 2:
logger.error("Usage: python script.py <create|delete>")
Expand All @@ -39,6 +42,11 @@ def getRequiredEnv(key):
imageId = getRequiredEnv("OVH_INSTANCE_IMAGE_ID")
region = getRequiredEnv("OVH_REGION")
authToken = getRequiredEnv("AUTH_TOKEN")
huggingFaceHubToken = getRequiredEnv("HUGGING_FACE_HUB_TOKEN")

f = open("docker-compose.yaml", "r")
dockerCompose = indentString(f.read(), 8)

userData = f"""
#cloud-config
Expand All @@ -55,17 +63,19 @@ def getRequiredEnv(key):
set -Eeuo pipefail
cd /home/ubuntu
curl -O https://raw.githubusercontent.com/SocialGouv/vllm-managed-instance/main/docker-compose.yaml
cat <<'EOF' > docker-compose.yaml
{dockerCompose}
EOF
echo "HOST=$(curl -4 ifconfig.me)" >> .env
echo "CREDENTIALS='$(htpasswd -nBb user {authToken})'" >> .env
echo "HUGGING_FACE_HUB_TOKEN='{huggingFaceHubToken}'" >> .env
docker compose up -d --build
touch /tmp/runcmd_finished
runcmd:
- su - ubuntu -c '/home/ubuntu/init.sh > init.log 2>&1'
"""


def findInstance():
instances = client.get(f"/cloud/project/{serviceName}/instance")
if not instances:
Expand Down

0 comments on commit 64ca607

Please sign in to comment.