Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add torchscript runtime and docker support #67

Merged
merged 18 commits into from
Feb 5, 2025

Conversation

CuriousDolphin
Copy link
Member

@CuriousDolphin CuriousDolphin commented Jan 27, 2025

Add Torchscript runtime, docker images and devcontainers.

Context

This pull request introduces comprehensive support for TorchScript runtime alongside the existing ONNX runtime, and adds devcontainer and dockerfile configurations for different development environments. These changes aim to provide more flexibility in model execution and simplify the development environment setup process.

KEY CHANGES

  • Add devcontainer and docker configurations for multiple development environments:
    • CPU-only configuration with OnnxRuntime
    • GPU configuration with OnnxRuntime
    • GPU configuration with Torchscript support
    • GPU configuration with TensorRT support
  • Enhance runtime system with support for multiple model formats:
    • Add TorchScript runtime implementation
    • Refactor ONNXRuntime implementation
    • Introduce BaseRuntime abstract class
  • Update dependency management:
    • Split GPU dependencies into separate extras (onnx, torch, tensorrt)
    • Add new optional dependencies for different runtime configurations
  • Improve documentation and examples:
    • Update README with new installation options
    • Add detailed runtime configuration documentation
    • Update playground notebook with new runtime examples
  • fix CI Matrix tests:
    • now CI tests work also on windows and macos

Impact

  • Development Environment: Affects how developers set up and interact with the development environment
  • Runtime Performance: Impacts model inference performance through new runtime options
  • Dependency Management: Changes how users install and manage SDK dependencies
  • Documentation: Updates how users understand and implement the SDK features

Technical details

  • Devcontainer Configuration: Implemented using JSON configurations with specific targets for different environments:

Dockerfile:

FROM python:3.12-slim-bullseye AS focoos-cpu
...
FROM ghcr.io/focoosai/deeplearning:base-cu12-cudnn9-py312-uv AS focoos-onnx
...
FROM focoos-onnx AS focoos-torch
....
FROM focoos-torch AS focoos-tensorrt

devcontainer.json

{
    "name": "Focoos CPU",
    "build": {
        "context": "../..",
        "dockerfile": "../../Dockerfile",
        "target": "focoos-cpu"
    }
}
  • Runtime System: Introduced new abstract base class and TorchscriptRuntime:
class BaseRuntime:
    @abstractmethod
    def __call__(self, im: np.ndarray, conf_threshold: float) -> sv.Detections:
        pass
  • Dependency Management Updated pyproject.toml with new extras:
[project.optional-dependencies]
cpu = ["onnxruntime==1.20.1"]
onnx = ["onnxruntime-gpu==1.20.1"]
tensorrt = ["onnxruntime-gpu==1.20.1","tensorrt==10.5.0"]
torch = ["torch==2.3.0","torchvision"]

The changes provide a more flexible and maintainable development environment while improving the SDK's performance and usability across different hardware configurations.

Copy link

github-actions bot commented Jan 27, 2025

Coverage

Coverage Report •
FileStmtsMissCoverMissing
__init__.py100100% 
focoos.py1160100% 
local_model.py630100% 
ports.py2480100% 
runtime.py1589738%28, 37–38, 112, 116, 120, 130, 132–133, 135–138, 141–143, 146, 149–151, 154, 157–158, 161–162, 165, 190–194, 196–197, 200–203, 205–206, 208, 212–215, 219–220, 222–224, 226–230, 232–233, 235–237, 241, 251–252, 262–266, 268, 270–271, 273–279, 283–286, 290–291, 293–294, 296–300, 302–303, 305–306, 308, 318–319
utils
   system.py85594%220–224
TOTAL102713886% 

Tests Skipped Failures Errors Time
109 0 💤 0 ❌ 0 🔥 6.660s ⏱️

@CuriousDolphin CuriousDolphin changed the title fix(ci): fix test to run on matrix.os add torchscript and docker Jan 27, 2025
@CuriousDolphin CuriousDolphin marked this pull request as ready for review January 29, 2025 09:43
- Rename `onnx` optional dependency to `cuda`
- Update Dockerfile to use `focoos-cuda` instead of `focoos-onnx`
- Remove deprecated devcontainer configurations
- Update README and documentation to reflect new runtime naming
- Simplify installation instructions for different runtime environments
@CuriousDolphin CuriousDolphin linked an issue Jan 31, 2025 that may be closed by this pull request
2 tasks
@CuriousDolphin CuriousDolphin force-pushed the feat/torchscript-docker branch from 4d2342e to dbe1fc5 Compare February 3, 2025 09:26
@CuriousDolphin CuriousDolphin removed a link to an issue Feb 5, 2025
2 tasks
@CuriousDolphin CuriousDolphin changed the title add torchscript and docker feat: add torchscript runtime and docker support Feb 5, 2025
Copy link
Member

@fcdl94 fcdl94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONNXRuntime sucks

@fcdl94 fcdl94 merged commit 2536b91 into main Feb 5, 2025
9 checks passed
@fcdl94 fcdl94 deleted the feat/torchscript-docker branch February 5, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants