Skip to content

Commit a3d8078

Browse files
committed
feat(pytorch2): bump deps, drop conda/xformers
1 parent 8929508 commit a3d8078

5 files changed

Lines changed: 42 additions & 42 deletions

File tree

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
ARG FROM_IMAGE="gadicc/diffusers-api-base:python3.9-pytorch1.12.1-cuda11.6-xformers"
1+
ARG FROM_IMAGE="pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime"
2+
# ARG FROM_IMAGE="gadicc/diffusers-api-base:python3.9-pytorch1.12.1-cuda11.6-xformers"
23
# You only need the -banana variant if you need banana's optimization
34
# i.e. not relevant if you're using RUNTIME_DOWNLOADS
45
# ARG FROM_IMAGE="gadicc/python3.9-pytorch1.12.1-cuda11.6-xformers-banana"
@@ -20,6 +21,7 @@ RUN if [ -n "$http_proxy" ] ; then \
2021
ARG REQUESTS_CA_BUNDLE=${http_proxy:+/usr/local/share/ca-certificates/squid-self-signed.crt}
2122

2223
ARG DEBIAN_FRONTEND=noninteractive
24+
RUN apt-get update && apt-get install -yqq git
2325

2426
FROM base AS patchmatch
2527
ARG USE_PATCHMATCH=0
@@ -67,15 +69,15 @@ RUN if [ "$USE_DREAMBOOTH" = "1" ] ; then \
6769
# By specifying the same torch version as conda, it won't download again.
6870
# Without this, it will upgrade torch, break xformers, make bigger image.
6971
# bitsandbytes==0.40.0.post4 had failed cuda detection on dreambooth test.
70-
pip install -r diffusers/examples/dreambooth/requirements.txt bitsandbytes==0.39.1 torch==1.12.1 ; \
72+
pip install -r diffusers/examples/dreambooth/requirements.txt ; \
7173
fi
7274
RUN if [ "$USE_DREAMBOOTH" = "1" ] ; then apt-get install git-lfs ; fi
7375

7476
ARG USE_REALESRGAN=1
75-
RUN if [ "$USE_REALESRGAN" = "1" ] ; then conda install -c pytorch torchvision ; fi
7677
RUN if [ "$USE_REALESRGAN" = "1" ] ; then apt-get install -y libgl1-mesa-glx libglib2.0-0 ; fi
7778
RUN if [ "$USE_REALESRGAN" = "1" ] ; then git clone https://github.com/xinntao/Real-ESRGAN.git ; fi
78-
RUN if [ "$USE_REALESRGAN" = "1" ] ; then pip install numba==0.57.1 chardet ; fi
79+
# RUN if [ "$USE_REALESRGAN" = "1" ] ; then pip install numba==0.57.1 chardet ; fi
80+
RUN if [ "$USE_REALESRGAN" = "1" ] ; then pip install basicsr==1.4.2 facexlib==0.2.5 gfpgan==1.3.8 ; fi
7981
RUN if [ "$USE_REALESRGAN" = "1" ] ; then cd Real-ESRGAN && python3 setup.py develop ; fi
8082

8183
COPY api/ .

api/app.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def truncateInputs(inputs: dict):
120120
return clone
121121

122122

123-
last_xformers_memory_efficient_attention = {}
123+
# last_xformers_memory_efficient_attention = {}
124124
last_attn_procs = None
125125
last_lora_weights = None
126126

@@ -132,7 +132,7 @@ async def inference(all_inputs: dict, response) -> dict:
132132
global pipelines
133133
global last_model_id
134134
global schedulers
135-
global last_xformers_memory_efficient_attention
135+
# global last_xformers_memory_efficient_attention
136136
global always_normalize_model_id
137137
global last_attn_procs
138138
global last_lora_weights
@@ -456,25 +456,25 @@ def sendStatus():
456456
model_inputs["mask_image"] = PIL.Image.fromarray(mask)
457457

458458
# Turning on takes 3ms and turning off 1ms... don't worry, I've got your back :)
459-
x_m_e_a = call_inputs.get("xformers_memory_efficient_attention", True)
460-
last_x_m_e_a = last_xformers_memory_efficient_attention.get(pipeline, None)
461-
if x_m_e_a != last_x_m_e_a:
462-
if x_m_e_a == True:
463-
print("pipeline.enable_xformers_memory_efficient_attention()")
464-
pipeline.enable_xformers_memory_efficient_attention() # default on
465-
elif x_m_e_a == False:
466-
print("pipeline.disable_xformers_memory_efficient_attention()")
467-
pipeline.disable_xformers_memory_efficient_attention()
468-
else:
469-
return {
470-
"$error": {
471-
"code": "INVALID_XFORMERS_MEMORY_EFFICIENT_ATTENTION_VALUE",
472-
"message": f"x_m_e_a expects True or False, not: {x_m_e_a}",
473-
"requested": x_m_e_a,
474-
"available": [True, False],
475-
}
476-
}
477-
last_xformers_memory_efficient_attention.update({pipeline: x_m_e_a})
459+
# x_m_e_a = call_inputs.get("xformers_memory_efficient_attention", True)
460+
# last_x_m_e_a = last_xformers_memory_efficient_attention.get(pipeline, None)
461+
# if x_m_e_a != last_x_m_e_a:
462+
# if x_m_e_a == True:
463+
# print("pipeline.enable_xformers_memory_efficient_attention()")
464+
# pipeline.enable_xformers_memory_efficient_attention() # default on
465+
# elif x_m_e_a == False:
466+
# print("pipeline.disable_xformers_memory_efficient_attention()")
467+
# pipeline.disable_xformers_memory_efficient_attention()
468+
# else:
469+
# return {
470+
# "$error": {
471+
# "code": "INVALID_XFORMERS_MEMORY_EFFICIENT_ATTENTION_VALUE",
472+
# "message": f"x_m_e_a expects True or False, not: {x_m_e_a}",
473+
# "requested": x_m_e_a,
474+
# "available": [True, False],
475+
# }
476+
# }
477+
# last_xformers_memory_efficient_attention.update({pipeline: x_m_e_a})
478478

479479
# Run the model
480480
# with autocast(device_id):

api/train_dreambooth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def TrainDreamBooth(model_id: str, pipeline, model_inputs, call_inputs, send_opt
159159
# 1.10.and an Nvidia Ampere GPU. Default to fp16 if a GPU is available else fp32.
160160
"prior_generation_precision": None, # "no", "fp32", "fp16", "bf16"
161161
"local_rank": -1,
162-
"enable_xformers_memory_efficient_attention": True, # DDA, was: None
162+
"enable_xformers_memory_efficient_attention": None,
163163
# Save more memory by using setting grads to None instead of zero. Be aware, that this changes certain
164164
# behaviors, so disable this argument if it causes any problems. More info:
165165
# https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html

requirements.txt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,23 @@ scikit-image==0.19.3
2525
accelerate==0.20.3
2626

2727
# triton==2.0.0.dev20221105
28-
triton==2.0.0.dev20221202
28+
# triton==2.0.0.dev20221202 until 2023-07-19
29+
triton==2.0.0.post1 # released 2023-03-17
2930

3031
ftfy==6.1.1
3132

3233
# spacy==3.4.3
3334
spacy==3.5.0
3435

35-
k-diffusion==0.0.12
36+
# k-diffusion==0.0.12 until 2023-07-19
37+
k-diffusion==0.0.15
3638

3739
# safetensors==0.2.8 until 2023-06-14
3840
safetensors==0.3.1
3941

40-
# must match conda installed version in Dockerfile
41-
torch==1.12.1
42-
# xformers 0.0.15.dev344+git.8910bb5 requires pyre-extensions==0.0.23
43-
pyre-extensions==0.0.23
42+
# torch==1.12.1 until 2023-07-19
43+
torch==2.0.1
44+
torchvision==0.15.2
4445

4546
# boto3==1.26.12
4647
boto3==1.26.57
@@ -58,10 +59,4 @@ tensorboard==2.12.0
5859

5960
xtarfile[zstd]==0.1.0
6061

61-
# runtime_downloads upsampling; TODO, make it a build option
62-
basicsr==1.4.2
63-
facexlib==0.2.5
64-
gfpgan==1.3.8
65-
# torch and torchvision must match
66-
# https://github.com/pytorch/vision#installation
67-
#torchvision==0.13.1 # do it from conda
62+
bitsandbytes==0.40.2 # released 2023-07-17

tests/integration/test_build_download.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def test_cloudcache_build_download():
1616
"MODEL_REVISION": "fp16",
1717
"MODEL_URL": "s3://", # <--
1818
}
19-
conda = "conda run --no-capture-output -n xformers"
19+
# conda = "conda run --no-capture-output -n xformers"
20+
conda = ""
2021
dda = getDDA(
2122
minio=minio,
2223
stream_logs=True,
@@ -59,7 +60,8 @@ def test_huggingface_build_download():
5960
"MODEL_PRECISION": "fp16",
6061
"MODEL_REVISION": "fp16",
6162
}
62-
conda = "conda run --no-capture-output -n xformers"
63+
# conda = "conda run --no-capture-output -n xformers"
64+
conda = ""
6365
dda = getDDA(
6466
stream_logs=True,
6567
environment=environment,
@@ -103,7 +105,8 @@ def test_checkpoint_url_build_download():
103105
"MODEL_REVISION": "fp16",
104106
"CHECKPOINT_URL": "https://huggingface.co/hakurei/waifu-diffusion-v1-3/resolve/main/wd-v1-3-float16.ckpt",
105107
}
106-
conda = "conda run --no-capture-output -n xformers"
108+
# conda = "conda run --no-capture-output -n xformers"
109+
conda = ""
107110
dda = getDDA(
108111
stream_logs=True,
109112
environment=environment,

0 commit comments

Comments
 (0)