Skip to content

Commit a39e3df

Browse files
committed
working but needs cleanup
1 parent afc248a commit a39e3df

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

Dockerfile

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
# Must use a Cuda version 11+
2-
FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel as base
2+
# FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel as base
3+
# xformers available precompiled for:
4+
# Python 3.9 or 3.10, CUDA 11.3 or 11.6, and PyTorch 1.12.1
5+
# https://github.com/facebookresearch/xformers/#getting-started
6+
FROM pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime as base
7+
#FROM nvcr.io/nvidia/pytorch:22.08-py3 as base
38
ENV DEBIAN_FRONTEND=noninteractive
49
RUN mkdir -p /root/.cache/pip
510
COPY root-cache/pip /root/.cache/pip
6-
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
11+
#RUN apt-get install gnupg2
12+
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
713
RUN apt-get update && apt-get install -yqq git
814

15+
#RUN apt install -yqq software-properties-common
16+
#RUN add-apt-repository ppa:deadsnakes/ppa
17+
#RUN apt update
18+
#RUN apt-get install -yqq python3.10
19+
#RUN ln -sf /usr/bin/python3.10 /usr/bin/python3
20+
#RUN ln -sf /usr/bin/python3.10 /usr/bin/python
21+
922
FROM base AS patchmatch
1023
ARG USE_PATCHMATCH=0
1124
WORKDIR /tmp
@@ -16,6 +29,16 @@ FROM base as output
1629
RUN mkdir /api
1730
WORKDIR /api
1831

32+
# We need python 3.9 or 3.10 for xformers
33+
# Yes, we install pytorch twice... will switch base image in future
34+
# RUN conda update -n base -c defaults conda
35+
RUN conda create -n xformers python=3.10
36+
SHELL ["conda", "run", "--no-capture-output", "-n", "xformers", "/bin/bash", "-c"]
37+
RUN python --version
38+
RUN conda install -c pytorch -c conda-forge cudatoolkit=11.6 pytorch=1.12.1
39+
RUN conda install xformers -c xformers/label/dev
40+
RUN pip install triton==2.0.0.dev20221105
41+
1942
# Install python packages
2043
RUN pip3 install --upgrade pip
2144
ADD requirements.txt requirements.txt
@@ -24,8 +47,9 @@ RUN pip3 install -r requirements.txt
2447
# Required to build flash attention
2548
# Turing: 7.5 (RTX 20s, Quadro), Ampere: 8.0 (A100), 8.6 (RTX 30s)
2649
# https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
27-
ENV FLASH_ATTENTION=0
28-
ENV TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6"
50+
# ENV FLASH_ATTENTION=0
51+
# ENV TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6"
52+
# this is built it into memory efficient attention now ! ^_^
2953

3054
ADD install.sh .
3155
RUN bash install.sh
@@ -83,3 +107,4 @@ ADD send.py .
83107
ADD app.py .
84108

85109
CMD python3 -u server.py
110+

app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ def inference(all_inputs: dict) -> dict:
273273
# with autocast("cuda"):
274274
# image = pipeline(**model_inputs).images[0]
275275

276+
pipeline.enable_xformers_memory_efficient_attention()
277+
276278
with torch.inference_mode():
277279
# autocast im2img and inpaint which are broken in 0.4.0, 0.4.1
278280
# still broken in 0.5.1

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ sanic==22.6.2
33
#git+https://github.com/huggingface/diffusers@v0.5.1
44
#git+https://github.com/HazyResearch/diffusers
55
transformers==4.22.2
6-
scipy==1.9.1
6+
scipy==1.9.3
77
requests_futures==1.0.0
8-
numpy==1.23.3
8+
numpy==1.23.4
99
scikit-image==0.19.3
10-
accelerate==0.13.2
10+
accelerate==0.13.2

0 commit comments

Comments
 (0)