Skip to content

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoinky3000 committed Jun 14, 2024
1 parent abfbf55 commit 8add99f
Show file tree
Hide file tree
Showing 14 changed files with 579 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Dev Branch Publish

env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

on:
push:
paths:
- '.github/workflows/build-dev.yml'
- 'build/**'
- 'scripts/**'
- 'SD Next/**'
- 'workspace/**'
- 'docker-bake.hcl'
- 'Dockerfile'
branches:
- 'dev'

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push
uses: docker/bake-action@v4
with:
push: true
targets: dev
provenance: false
66 changes: 66 additions & 0 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Main Branch Publish

env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

on:
push:
paths:
- '.github/workflows/build-main.yml'
- 'build/**'
- 'scripts/**'
- 'SD Next/**'
- 'workspace/**'
- 'docker-bake.hcl'
- 'Dockerfile'
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- cu118
- cu120
- cu121
- cu122
- cu123
- cu124
- cu125
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push
uses: docker/bake-action@v4
with:
push: true
targets: ${{ matrix.target }}
provenance: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bat
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CHANGE LOG
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG FROM_IMG
FROM ${FROM_IMG}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY --chmod=755 build/* ./

COPY --chmod=755 scripts/* ./

RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
/setup.sh

WORKDIR /workspace

ARG DEFAULT_TORCH_CU
ARG SD_NEXT_COMMIT
RUN /sdnext-setup.sh

COPY ./workspace/* ./

COPY ["./SD Next/*", "./SD Next/"]

ARG NIGHTLY_TORCH_CU
ENV NIGHTLY_COMMAND="--pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/${NIGHTLY_TORCH_CU}"

LABEL org.opencontainers.image.source https://github.com/Yoinky3000/sd-next-docker
LABEL org.opencontainers.image.description "A docker image to automatically setup everything you needed to run SD Next in a container"

CMD /jupyter-start.sh
46 changes: 46 additions & 0 deletions SD Next/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"sdp_options": [
"Flash attention",
"Memory attention",
"Math attention"
],
"xformers_options": [
"Flash attention"
],
"opt_channelslast": true,
"cuda_compile": [],
"nncf_compress_weights": [],
"ipex_optimize": [],
"openvino_devices": [],
"nncf_quantize": [],
"hypertile_unet_enabled": true,
"inference_mode": "inference-mode",
"diffusers_model_load_variant": "fp16",
"diffusers_vae_load_variant": "fp16",
"styles_dir": "models/styles",
"save_to_dirs": true,
"samples_filename_pattern": "[seq]-[model_name]-[seed]",
"directories_max_prompt_words": 30,
"theme_type": "Modern",
"gradio_theme": "Eoan-Alpha",
"quicksettings_list": [
"sd_model_checkpoint"
],
"show_samplers": [],
"postprocessing_enable_in_main_ui": [],
"postprocessing_operation_order": [],
"interrogate_clip_skip_categories": [
"artists",
"movements",
"flavors"
],
"extra_networks": [
"All"
],
"disabled_extensions": [],
"clip_skip": 1,
"uni_pc_lower_order_final": true,
"uni_pc_order": 2,
"uiux_hide_legacy": false,
"diffusers_vae_upcast": "false"
}
57 changes: 57 additions & 0 deletions build/sdnext-preinstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Edited based on the launch.py of SD Next as of the time at commit - 84f9caaffe8eae40f2f597c09faccb59a4eab2b7

import installer
import time
import sys
args = None
parser = None
script_path = None
extensions_dir = None
def init_args():
global parser, args
import modules.cmd_args
parser = modules.cmd_args.parser
installer.add_args(parser)
args, _ = parser.parse_known_args()
def init_paths():
global script_path, extensions_dir
import modules.paths
modules.paths.register_paths()
script_path = modules.paths.script_path
extensions_dir = modules.paths.extensions_dir
def main():
global args
installer.ensure_base_requirements()
init_args()
installer.args = args
installer.setup_logging()
installer.get_logfile()
try:
sys.excepthook = installer.custom_excepthook
except Exception:
pass
installer.read_options()
installer.check_python()
installer.check_version()
installer.log.info(f'Platform: {installer.print_dict(installer.get_platform())}')
installer.check_torch()
installer.install('onnxruntime-gpu', 'onnxruntime-gpu', ignore=True)
installer.install('onnx', 'onnx', ignore=True)
installer.check_diffusers()
installer.install_requirements()
installer.install_packages()
installer.install_submodules()
init_paths()
installer.install_extensions()
installer.install_requirements()
installer.update_wiki()
if installer.errors == 0:
installer.log.debug(f'Setup complete without errors: {round(time.time())}')
else:
installer.log.warning(f'Setup complete with errors: {installer.errors}')
installer.log.warning(f'See log file for more details: {installer.log_file}')

installer.install("matplotlib-inline")
installer.install("basicsr")
installer.install("gfpgan")
main()
24 changes: 24 additions & 0 deletions build/sdnext-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Clone SD Next (master branch)
git clone https://github.com/vladmandic/automatic "SD Next"

# Setup git
cd ./SD\ Next
git reset --hard ${SD_NEXT_COMMIT}
git submodule --quiet update --init --recursive
git submodule --quiet sync --recursive

# Create and activate venv
python3 -m venv venv
source ./venv/bin/activate

# Pre install all python dependencies
cp /sdnext-preinstall.py ./sdnext-preinstall.py
export TORCH_COMMAND="torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/${DEFAULT_TORCH_CU}" && \
python3 ./sdnext-preinstall.py && \
echo -e "\nInstallation completed, verifying..." && \
python3 ./sdnext-preinstall.py > /dev/null
rm ./sdnext-preinstall.py

deactivate
13 changes: 13 additions & 0 deletions build/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

apt update -y
apt upgrade -y
apt install -y git \
python3.10 \
pythonpy \
python3.10-venv \
python3-pip \
curl \
wget

pip install jupyterlab
83 changes: 83 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
variable "REGISTRY" {
default = "docker.io"
}

variable "IMAGE" {
default = "yoink3000/sd-next-docker"
}

variable "RELEASE" {
default = "1.0.0"
}

variable "SD_NEXT_COMMIT" {
default = "84f9caaffe8eae40f2f597c09faccb59a4eab2b7"
}

variable TAG_INFO {
default = {
cu118: {
IMG: "11.8.0-cudnn8",
DEFAULT_TORCH: "cu118",
NIGHTLY_TORCH: "cu118",
},
cu120: {
IMG: "12.0.1-cudnn8",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu121",
},
cu121: {
IMG: "12.1.1-cudnn8",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu121",
},
cu122: {
IMG: "12.2.2-cudnn8",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu121",
},
cu123: {
IMG: "12.3.2-cudnn9",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu121",
},
cu124: {
IMG: "12.4.1-cudnn",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu124",
},
cu125: {
IMG: "12.5.0",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu124",
},
dev: {
IMG: "12.4.1-cudnn",
DEFAULT_TORCH: "cu121",
NIGHTLY_TORCH: "cu124",
},
}
}

function "autoTag" {
params = [tag]
result = "${tag}" == "dev" ? ["${REGISTRY}/${IMAGE}:dev"] : "${tag}" == "cu124" ? ["${REGISTRY}/${IMAGE}:${RELEASE}-${tag}", "${REGISTRY}/${IMAGE}:latest"] : ["${REGISTRY}/${IMAGE}:${RELEASE}-${tag}"]
}

target "default" {
matrix = {
TAG = ["cu118", "cu120", "cu121", "cu122", "cu123", "cu124", "cu125", "dev"]
}
name = "${TAG}"
dockerfile = "./Dockerfile"
args = {
FROM_IMG = "nvidia/cuda:${TAG_INFO["${TAG}"].IMG}-devel-ubuntu22.04"
DEFAULT_TORCH_CU = "${TAG_INFO["${TAG}"].DEFAULT_TORCH}"
NIGHTLY_TORCH_CU = "${TAG_INFO["${TAG}"].NIGHTLY_TORCH}"
SD_NEXT_COMMIT = "${SD_NEXT_COMMIT}"
}
tags = autoTag("${TAG}")
platforms = ["linux/amd64"]
cache-from = ["${autoTag("${TAG}")[0]}"]
cache-to = ["${autoTag("${TAG}")[0]}"]
}
Loading

0 comments on commit 8add99f

Please sign in to comment.