initial commit

This commit is contained in:
ale 2022-11-18 23:46:24 +01:00
commit 4c2ddd2806
3 changed files with 67 additions and 0 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM tensorflow/tensorflow:devel-gpu
ENV DEBIAN_FRONTEND=noninteractive
ENV NVIDIA_VISIBLE_DEVICES=all
ENV CUDA_VISIBLE_DEVICES=0
ENV PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:128
RUN apt update && apt install -y build-essential cmake git aria2 python3 cuda-runtime-11-8 && apt clean
RUN git clone --depth 1 https://github.com/basujindal/stable-diffusion /stable-diffusion
RUN pip install --upgrade pip
RUN pip install transformers==4.19.2 diffusers invisible-watermark omegaconf einops torchvision pytorch_lightning clip kornia
WORKDIR /stable-diffusion
RUN pip install -e .
RUN git clone --depth 1 https://github.com/CompVis/taming-transformers && mv taming-transformers/taming . && rm -rf taming-transformers
RUN aria2c --seed-time=0 "magnet:?xt=urn:btih:2daef5b5f63a16a9af9169a529b1a773fc452637&dn=v1-5-pruned-emaonly.ckpt&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce&tr=udp%3a%2f%2f9.rarbg.com%3a2810%2fannounce&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a6969%2fannounce&tr=udp%3a%2f%2fopentracker.i2p.rocks%3a6969%2fannounce&tr=https%3a%2f%2fopentracker.i2p.rocks%3a443%2fannounce&tr=http%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.torrent.eu.org%3a451%2fannounce&tr=udp%3a%2f%2fopen.stealth.si%3a80%2fannounce&tr=udp%3a%2f%2fvibe.sleepyinternetfun.xyz%3a1738%2fannounce&tr=udp%3a%2f%2ftracker2.dler.org%3a80%2fannounce&tr=udp%3a%2f%2ftracker1.bt.moack.co.kr%3a80%2fannounce&tr=udp%3a%2f%2ftracker.zemoj.com%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.tiny-vps.com%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.theoks.net%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.publictracker.xyz%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.monitorit4.me%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.moeking.me%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.lelux.fi%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.dler.org%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.army%3a6969%2fannounce"
RUN mkdir -p models/ldm/stable-diffusion-v1/ && ln -s $PWD/v1-5-pruned-emaonly.ckpt $PWD/models/ldm/stable-diffusion-v1/model.ckpt
RUN sed -i "s/import argparse, os, re/import argparse, os, sys, re\nsys.path.insert(0, os.getcwd())/" optimizedSD/optimized_txt2img.py optimizedSD/optimized_img2img.py
RUN python optimizedSD/optimized_txt2img.py 2> /dev/null || exit 0
ENTRYPOINT ["python", "optimizedSD/optimized_txt2img.py", "--H", "512", "--W", "512", "--n_samples", "1", "--precision", "full", "--outdir", "/output", "--format", "jpg", "--prompt"]

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# Docker Stable Diffusion
## Dirty docker project to run Stable Diffusion AI with [this](https://github.com/basujindal/stable-diffusion/) optimized project for low memory Nvidia graphics cards ~ 4GB, final Docker image must be 22.3GB of size
### This project need `docker` with `docker-compose` optional, necessary [nvidia runtime](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html) and [latest nvidia drivers](https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html#ubuntu-lts) installed
## Build
```
docker-compose build
```
## Run
```
docker-compose run --rm stable-diffusion "input terms"
```
## Output image
```
JPG file output is in the ./output folder
```
## Generate from existing image
```
docker-compose run --rm --entrypoint "python optimizedSD/optimized_img2img.py" stable-diffusion --outdir /output --n_samples 1 --precision full --prompt "input terms" --format jpg --H 512 --W 512 --init-img /output/input.png
```
## License
```
MIT
```

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
version: '2'
services:
stable-diffusion:
build: ./
image: stable-diffusion
container_name: stable-diffusion
restart: "no"
devices:
- /dev/nvidia0
- /dev/nvidiactl
- /dev/nvidia-uvm
- /dev/nvidia-uvm-tools
volumes:
- ./output:/output