Skip to content

Commit

Permalink
docs: add Docker and devcontainer support
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousDolphin committed Jan 28, 2025
1 parent 3956533 commit 461df5a
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 6 deletions.
66 changes: 66 additions & 0 deletions .devcontainer/cpu/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "Focoos CPU",
"build": {
"context": "../..",
"dockerfile": "../../Dockerfile",
"target": "focoos-cpu"
},
"shutdownAction": "none",
"remoteUser": "root",
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"postCreateCommand": "uv pip install -e .[dev]",
"remoteEnv": {
"UV_SYSTEM_PYTHON": "true"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
// git
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
},
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/iterative/features/nvtop:1": {},
},
"customizations": {
"devpod": {
"podManifestTemplate": ".devcontainer/pod_manifest.yaml"
},
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.terminal.activateEnvInCurrentTerminal": true,
},
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"ms-python.python",
"vscode.git",
"ms-azuretools.vscode-docker",
"vscode.ipynb",
"waderyan.gitblame",
"michelemelluso.gitignore",
"amazonwebservices.aws-toolkit-vscode",
"naumovs.color-highlight",
"mindaro-dev.file-downloader",
"donjayamanne.githistory",
"github.vscode-github-actions",
"seatonjiang.gitmoji-vscode",
"ms-vscode.remote-repositories",
"donjayamanne.python-environment-manager",
"ninoseki.vscode-pylens",
"ninoseki.vscode-mogami",
"charliermarsh.ruff"
]
}
}
}
79 changes: 79 additions & 0 deletions .devcontainer/gpu-base/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "Focoos GPU (OnnxRuntime)",
"build": {
"target": "focoos-onnx",
"context": "../..",
"dockerfile": "../../Dockerfile",
},
"shutdownAction": "none",
"remoteUser": "root",
"hostRequirements": {
"gpu": "optional"
},
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"postCreateCommand": "uv pip install -e .[onnx,dev]",
"remoteEnv": {
"UV_SYSTEM_PYTHON": "true"
},
"runArgs": [
"--gpus=all",
"--ipc=host",
"--runtime=nvidia",
"--ulimit=memlock=-1",
"--ulimit=stack=67108864",
"--privileged"
],
"postStartCommand": [
"nvidia-smi"
],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
// git
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
},
"ghcr.io/iterative/features/nvtop:1": {},
},
"customizations": {
"devpod": {
"podManifestTemplate": ".devcontainer/pod_manifest.yaml"
},
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.terminal.activateEnvInCurrentTerminal": true,
},
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"ms-python.python",
"vscode.git",
"ms-azuretools.vscode-docker",
"vscode.ipynb",
"waderyan.gitblame",
"michelemelluso.gitignore",
"amazonwebservices.aws-toolkit-vscode",
"naumovs.color-highlight",
"mindaro-dev.file-downloader",
"donjayamanne.githistory",
"github.vscode-github-actions",
"seatonjiang.gitmoji-vscode",
"ms-vscode.remote-repositories",
"donjayamanne.python-environment-manager",
"ninoseki.vscode-pylens",
"ninoseki.vscode-mogami",
"charliermarsh.ruff"
]
}
}
}
81 changes: 81 additions & 0 deletions .devcontainer/gpu-tenosrrt/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "Focoos GPU (OnnxRuntime, Torch, TensorRT)",

"build": {
"context": "../..",
"dockerfile": "../../Dockerfile",
"target": "focoos-tensorrt"
},
"shutdownAction": "none",
"remoteUser": "root",
"hostRequirements": {
"gpu": "optional"
},
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"postCreateCommand": "uv pip install -e .[tensorrt,dev]",
"remoteEnv": {
"UV_SYSTEM_PYTHON": "true"
},
"runArgs": [
"--gpus=all",
"--ipc=host",
"--runtime=nvidia",
"--ulimit=memlock=-1",
"--ulimit=stack=67108864",
"--privileged"
],
"postStartCommand": [
"nvidia-smi"
],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
// git
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
},
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/iterative/features/nvtop:1": {},
},
"customizations": {
"devpod": {
"podManifestTemplate": ".devcontainer/pod_manifest.yaml"
},
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.terminal.activateEnvInCurrentTerminal": true,
},
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"ms-python.python",
"vscode.git",
"ms-azuretools.vscode-docker",
"vscode.ipynb",
"waderyan.gitblame",
"michelemelluso.gitignore",
"amazonwebservices.aws-toolkit-vscode",
"naumovs.color-highlight",
"mindaro-dev.file-downloader",
"donjayamanne.githistory",
"github.vscode-github-actions",
"seatonjiang.gitmoji-vscode",
"ms-vscode.remote-repositories",
"donjayamanne.python-environment-manager",
"ninoseki.vscode-pylens",
"ninoseki.vscode-mogami",
"charliermarsh.ruff"
]
}
}
}
80 changes: 80 additions & 0 deletions .devcontainer/gpu-torch/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "Focoos GPU (OnnxRuntime,Torch)",
"build": {
"context": "../..",
"dockerfile": "../../Dockerfile",
"target": "focoos-torch"
},
"shutdownAction": "none",
"remoteUser": "root",
"hostRequirements": {
"gpu": "optional"
},
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"postCreateCommand": "uv pip install -e .[torch,dev]",
"remoteEnv": {
"UV_SYSTEM_PYTHON": "true"
},
"runArgs": [
"--gpus=all",
"--ipc=host",
"--runtime=nvidia",
"--ulimit=memlock=-1",
"--ulimit=stack=67108864",
"--privileged"
],
"postStartCommand": [
"nvidia-smi"
],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
// git
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
},
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/iterative/features/nvtop:1": {},
},
"customizations": {
"devpod": {
"podManifestTemplate": ".devcontainer/pod_manifest.yaml"
},
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.terminal.activateEnvInCurrentTerminal": true,
},
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"ms-python.python",
"vscode.git",
"ms-azuretools.vscode-docker",
"vscode.ipynb",
"waderyan.gitblame",
"michelemelluso.gitignore",
"amazonwebservices.aws-toolkit-vscode",
"naumovs.color-highlight",
"mindaro-dev.file-downloader",
"donjayamanne.githistory",
"github.vscode-github-actions",
"seatonjiang.gitmoji-vscode",
"ms-vscode.remote-repositories",
"donjayamanne.python-environment-manager",
"ninoseki.vscode-pylens",
"ninoseki.vscode-mogami",
"charliermarsh.ruff"
]
}
}
}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
- name: 📦 Install dependencies
run: uv pip install .[cpu,dev]
- name: 📦 Install dev dependencies
run: uv pip install .[dev]
- name: 🧪 Run test
run: make test
- name: 📊 Generate test coverage report
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM python:3.12-slim-bullseye AS focoos-cpu
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
LABEL authors="focoos.ai"
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential git ffmpeg libsm6 libxext6 gcc libmagic1 wget make cmake
WORKDIR /app
COPY focoos ./focoos
COPY pyproject.toml ./pyproject.toml
RUN uv pip install --system -e .


FROM ghcr.io/focoosai/deeplearning:base-cu12-cudnn9-py312-uv AS focoos-onnx
LABEL authors="focoos.ai"

WORKDIR /app

COPY focoos ./focoos
COPY pyproject.toml ./pyproject.toml
RUN uv pip install --system -e .[onnx]


FROM focoos-onnx AS focoos-torch
RUN uv pip install --system -e .[torch]

FROM focoos-torch AS focoos-tensorrt
RUN apt-get update && apt-get install -y \
wget lsb-release && \
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i cuda-keyring_1.1-1_all.deb && \
apt-get update && apt-get install -y \
tensorrt \
python3-libnvinfer-dev \
uff-converter-tf && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN uv pip install --system -e .[tensorrt]
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Tests](https://github.com/FocoosAI/focoos/actions/workflows/test.yml/badge.svg??event=push&branch=main)

# Focoos pre-trained models

| Model Name | Task | Metrics | Domain |
Expand All @@ -21,13 +23,12 @@ Focoos supports both cloud and local inference, and enables training on the clou
### Key Features

- **Pre-trained Models**: A wide range of pre-trained models for different tasks and domains.
- **Multiple Inference Runtimes**: Support for various inference runtimes including CPU, GPU, Torchscript CUDA, OnnxRuntime CUDA, and OnnxRuntime TensorRT.
- **Cloud Inference**: API to Focoos cloud inference.
- **Local Inference**: local inference, making it easy to deploy models on the local machine.
- **Cloud Training**: Train user models on the focoos cloud.
- **Cloud Training**: Train custom models with the Focoos cloud.
- **Multiple Local Inference Runtimes**: Support for various inference runtimes including CPU, GPU, Torchscript CUDA, OnnxRuntime CUDA, and OnnxRuntime TensorRT.
- **Model Monitoring**: Monitor model performance and metrics.

![Tests](https://github.com/FocoosAI/focoos/actions/workflows/test.yml/badge.svg??event=push&branch=main)


# 🐍 Setup
We recommend using [UV](https://docs.astral.sh/uv/) as a package manager and environment manager for a streamlined dependency management experience.
Expand Down Expand Up @@ -111,3 +112,13 @@ model = focoos.get_local_model("focoos_object365")

detections = model.infer("./image.jpg", threshold=0.4)
```


## Docker and devcontainers
For container support, Focoos offers four different Docker images:
- `focoos-cpu`: only CPU
- `focoos-onnx`: Includes ONNX support
- `focoos-torch`: Includes ONNX and Torchscript support
- `focoos-tensorrt`: Includes ONNX, Torchscript, and TensorRT support

This repository also includes a devcontainer configuration for each of the above images. You can launch these devcontainers in Visual Studio Code for a seamless development experience.

0 comments on commit 461df5a

Please sign in to comment.