From 50d0f2fa1ea037b8bf6c048d02e20aaf3035caf7 Mon Sep 17 00:00:00 2001 From: Abdellah derfoufi <16905576+geekloper@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:18:04 +0200 Subject: [PATCH] Added NVIDIA GPU support to Docker (#1231) * Added NVIDIA GPU support to Docker * feat: Added NVIDIA GPU support to Docker --------- Co-authored-by: Abdellah Derfoufi --- Dockerfile | 24 +++++++++++++++++++++--- docker-compose.yml | 9 ++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71240b7..e86e8bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM python:3.10-bullseye +FROM nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 EXPOSE 7865 @@ -8,9 +8,27 @@ WORKDIR /app COPY . . -RUN apt update && apt install -y -qq ffmpeg aria2 && apt clean +# Install dependenceis to add PPAs +RUN apt-get update && \ + apt-get install -y -qq ffmpeg aria2 && apt clean && \ + apt-get install -y software-properties-common && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -RUN pip3 install --no-cache-dir -r requirements.txt +# Add the deadsnakes PPA to get Python 3.9 +RUN add-apt-repository ppa:deadsnakes/ppa + +# Install Python 3.9 and pip +RUN apt-get update && \ + apt-get install -y build-essential python-dev python3-dev python3.9-distutils python3.9-dev python3.9 curl && \ + apt-get clean && \ + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 && \ + curl https://bootstrap.pypa.io/get-pip.py | python3.9 + +# Set Python 3.9 as the default +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 + +RUN python3 -m pip install --no-cache-dir -r requirements.txt RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D40k.pth -d assets/pretrained_v2/ -o D40k.pth RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G40k.pth -d assets/pretrained_v2/ -o G40k.pth diff --git a/docker-compose.yml b/docker-compose.yml index a5db88d..0768b30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,4 +10,11 @@ services: - ./opt:/app/opt # - ./dataset:/app/dataset # you can use this folder in order to provide your dataset for model training ports: - - 7865:7865 \ No newline at end of file + - 7865:7865 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] \ No newline at end of file