Spaces:
Sleeping
Sleeping
Hugo Rodrigues
commited on
Commit
·
590ca00
1
Parent(s):
130d592
add nvidia docker image
Browse files- .dockerignore +34 -0
- Dockerfile +34 -18
- README.Docker.md +22 -0
- README.md +2 -0
- compose.yaml +51 -0
- requirements.txt +1 -2
.dockerignore
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Include any files or directories that you don't want to be copied to your
|
2 |
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
3 |
+
#
|
4 |
+
# For more help, visit the .dockerignore file reference guide at
|
5 |
+
# https://docs.docker.com/go/build-context-dockerignore/
|
6 |
+
|
7 |
+
**/.DS_Store
|
8 |
+
**/__pycache__
|
9 |
+
**/.venv
|
10 |
+
**/.classpath
|
11 |
+
**/.dockerignore
|
12 |
+
**/.env
|
13 |
+
**/.git
|
14 |
+
**/.gitignore
|
15 |
+
**/.project
|
16 |
+
**/.settings
|
17 |
+
**/.toolstarget
|
18 |
+
**/.vs
|
19 |
+
**/.vscode
|
20 |
+
**/*.*proj.user
|
21 |
+
**/*.dbmdl
|
22 |
+
**/*.jfm
|
23 |
+
**/bin
|
24 |
+
**/charts
|
25 |
+
**/docker-compose*
|
26 |
+
**/compose*
|
27 |
+
**/Dockerfile*
|
28 |
+
**/node_modules
|
29 |
+
**/npm-debug.log
|
30 |
+
**/obj
|
31 |
+
**/secrets.dev.yaml
|
32 |
+
**/values.dev.yaml
|
33 |
+
LICENSE
|
34 |
+
README.md
|
Dockerfile
CHANGED
@@ -1,27 +1,43 @@
|
|
1 |
-
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
WORKDIR /code
|
6 |
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
#
|
11 |
-
|
|
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
RUN useradd -m -u 1000 user
|
15 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
USER user
|
17 |
-
# Set home to the user's home directory
|
18 |
-
ENV HOME=/home/user \
|
19 |
-
PATH=/home/user/.local/bin:$PATH
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
|
27 |
-
|
|
|
|
1 |
+
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
|
2 |
+
LABEL maintainer="Hugging Face"
|
3 |
|
4 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
5 |
|
6 |
+
RUN apt update
|
7 |
+
RUN apt install -y git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg
|
8 |
+
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
9 |
+
# RUN apt-get install -y git libsndfile1-dev tesseract-ocr espeak-ng ffmpeg
|
10 |
+
# Prevents Python from writing pyc files.
|
11 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
12 |
+
ENV OMP_NUM_THREADS=1
|
13 |
|
14 |
+
# Keeps Python from buffering stdout and stderr to avoid situations where
|
15 |
+
# the application crashes without emitting any logs due to buffering.
|
16 |
+
ENV PYTHONUNBUFFERED=1
|
17 |
|
18 |
+
ENV HF_DATASETS_CACHE="/app/models"
|
19 |
+
|
20 |
+
WORKDIR /app
|
21 |
+
|
22 |
+
# Create a non-privileged user that the app will run under.
|
23 |
+
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
24 |
RUN useradd -m -u 1000 user
|
25 |
+
# Download dependencies as a separate step to take advantage of Docker's caching.
|
26 |
+
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
27 |
+
# Leverage a bind mount to requirements.txt to avoid having to copy them into
|
28 |
+
# into this layer.
|
29 |
+
RUN --mount=type=cache,target=/root/.cache/pip \
|
30 |
+
--mount=type=bind,source=requirements.txt,target=requirements.txt \
|
31 |
+
python3 -m pip install -r requirements.txt
|
32 |
+
|
33 |
+
# Switch to the non-privileged user to run the application.
|
34 |
USER user
|
|
|
|
|
|
|
35 |
|
36 |
+
# Copy the source code into the container.
|
37 |
+
COPY . .
|
38 |
|
39 |
+
# Expose the port that the application listens on.
|
40 |
+
EXPOSE 8088
|
41 |
|
42 |
+
# Run the application.
|
43 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.Docker.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### Building and running your application
|
2 |
+
|
3 |
+
When you're ready, start your application by running:
|
4 |
+
`docker compose up --build`.
|
5 |
+
|
6 |
+
Your application will be available at http://localhost:8088.
|
7 |
+
|
8 |
+
### Deploying your application to the cloud
|
9 |
+
|
10 |
+
First, build your image, e.g.: `docker build -t myapp .`.
|
11 |
+
If your cloud uses a different CPU architecture than your development
|
12 |
+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
|
13 |
+
you'll want to build the image for that platform, e.g.:
|
14 |
+
`docker build --platform=linux/amd64 -t myapp .`.
|
15 |
+
|
16 |
+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
|
17 |
+
|
18 |
+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
|
19 |
+
docs for more detail on building and pushing.
|
20 |
+
|
21 |
+
### References
|
22 |
+
* [Docker's Python guide](https://docs.docker.com/language/python/)
|
README.md
CHANGED
@@ -16,4 +16,6 @@ license: apache-2.0
|
|
16 |
|
17 |
- Deploy whisper on GPU
|
18 |
|
|
|
|
|
19 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
16 |
|
17 |
- Deploy whisper on GPU
|
18 |
|
19 |
+
- Use volumes cache export HF_DATASETS_CACHE="/path/to/another/directory"
|
20 |
+
|
21 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
compose.yaml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Comments are provided throughout this file to help you get started.
|
2 |
+
# If you need more help, visit the Docker compose reference guide at
|
3 |
+
# https://docs.docker.com/go/compose-spec-reference/
|
4 |
+
|
5 |
+
# Here the instructions define your application as a service called "server".
|
6 |
+
# This service is built from the Dockerfile in the current directory.
|
7 |
+
# You can add other services your application may depend on here, such as a
|
8 |
+
# database or a cache. For examples, see the Awesome Compose repository:
|
9 |
+
# https://github.com/docker/awesome-compose
|
10 |
+
services:
|
11 |
+
server:
|
12 |
+
build:
|
13 |
+
context: .
|
14 |
+
ports:
|
15 |
+
- 8088:7860
|
16 |
+
volumes:
|
17 |
+
- /Users/hugorodrigues/Projects/AI/HF/whisper:/app:rw
|
18 |
+
|
19 |
+
# The commented out section below is an example of how to define a PostgreSQL
|
20 |
+
# database that your application can use. `depends_on` tells Docker Compose to
|
21 |
+
# start the database before your application. The `db-data` volume persists the
|
22 |
+
# database data between container restarts. The `db-password` secret is used
|
23 |
+
# to set the database password. You must create `db/password.txt` and add
|
24 |
+
# a password of your choosing to it before running `docker compose up`.
|
25 |
+
# depends_on:
|
26 |
+
# db:
|
27 |
+
# condition: service_healthy
|
28 |
+
# db:
|
29 |
+
# image: postgres
|
30 |
+
# restart: always
|
31 |
+
# user: postgres
|
32 |
+
# secrets:
|
33 |
+
# - db-password
|
34 |
+
# volumes:
|
35 |
+
# - db-data:/var/lib/postgresql/data
|
36 |
+
# environment:
|
37 |
+
# - POSTGRES_DB=example
|
38 |
+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
|
39 |
+
# expose:
|
40 |
+
# - 5432
|
41 |
+
# healthcheck:
|
42 |
+
# test: [ "CMD", "pg_isready" ]
|
43 |
+
# interval: 10s
|
44 |
+
# timeout: 5s
|
45 |
+
# retries: 5
|
46 |
+
# volumes:
|
47 |
+
# db-data:
|
48 |
+
# secrets:
|
49 |
+
# db-password:
|
50 |
+
# file: db/password.txt
|
51 |
+
|
requirements.txt
CHANGED
@@ -2,8 +2,7 @@ fastapi
|
|
2 |
pydantic
|
3 |
typing
|
4 |
transformers
|
|
|
5 |
torch
|
6 |
-
requests
|
7 |
-
sentencepiece
|
8 |
uvicorn[standard]
|
9 |
ffmpeg
|
|
|
2 |
pydantic
|
3 |
typing
|
4 |
transformers
|
5 |
+
python-multipart
|
6 |
torch
|
|
|
|
|
7 |
uvicorn[standard]
|
8 |
ffmpeg
|