200 Ai Ml Applications

title: “AI/ML Application Containerization” tags: [“kb”]

AI/ML Application Containerization

This section details the containerization specifics for AI and Machine Learning applications within the project.

1. Core Principles

  • Base Image: Primarily uses nvidia/cuda:11.7.1-runtime-ubuntu20.04 to provide a GPU-enabled Ubuntu environment with CUDA capabilities.
  • Reproducibility: Application code is typically cloned directly from Git repositories using git clone and then explicitly version-pinned with git reset --hard <commit_hash>.
  • Dependency Management: Varies between Miniconda and Python’s virtualenv/pip based on the application’s requirements.

2. Key AI/ML Applications and Their Dockerfiles

2.1. hlky/stable-diffusion Web UI Variant

  • Dockerfile: Specific Dockerfile variant for an hlky fork of the Stable Diffusion web UI.
  • Environment Management: Leverages Miniconda.
  • Features: Includes a textual inversion patch.
  • Git Repos:
    • https://github.com/hlky/stable-diffusion.git
    • https://github.com/hlky/sd-enable-textual-inversion.git
  • Running: Exposes port 7860. Entrypoint: python3 -u scripts/webui.py.
  • Model Handling: Includes logic to dynamically link pre-downloaded models from a /models volume.

2.2. naifu AI Service

  • Dockerfile: Defines the Docker image for the naifu AI service (a FastAPI application).
  • Environment Management: Uses virtualenv and pip for Python dependency management.
  • Key Files:
    • requirements.txt: Specifies Python dependencies including torch, transformers, fastapi, uvicorn.
    • main.py: The core FastAPI application for image generation, text generation, and tag prediction via API endpoints.
  • Git Repo: https://gitea.cheapassbox.com/acmcarther/naifu.git
  • Running: Exposes port 6969. Entrypoint: ./run.sh.

2.3. AUTOMATIC1111/stable-diffusion-webui Variant

  • Dockerfile: Defines the Docker image for the popular AUTOMATIC1111 Stable Diffusion web UI.
  • Dependency Management: Uses pip.
  • Included Libraries: Integrates several AI enhancement libraries such as CodeFormer, BLIP, k-diffusion.
  • Git Repos:
    • https://github.com/CompVis/stable-diffusion.git
    • https://github.com/sczhou/CodeFormer.git
    • https://github.com/salesforce/BLIP.git
    • https://github.com/CompVis/taming-transformers.git
    • https://github.com/crowsonkb/k-diffusion.git
    • https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
    • https://github.com/TencentARC/GFPGAN.git
    • https://github.com/openai/CLIP.git
  • Configuration: config.json is copied into the image, detailing output directories, image generation parameters, and post-processing settings.
  • Running: Exposes port 7860. Entrypoint: python3 -u ../../webui.py. Requires mounting config.json and potentially other docker helper scripts.