Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pins torch to >= 2.0 and applies recommendation for faster model loding #279

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions 06_gpu_and_ml/stable_diffusion/stable_diffusion_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def download_models():
"transformers",
"triton",
"safetensors",
"torch>=2.0",
)
.pip_install("xformers", pre=True)
.run_function(
Expand Down Expand Up @@ -133,20 +134,21 @@ def __enter__(self):

torch.backends.cuda.matmul.allow_tf32 = True

scheduler = diffusers.DPMSolverMultistepScheduler.from_pretrained(
cache_path,
subfolder="scheduler",
solver_order=2,
prediction_type="epsilon",
thresholding=False,
algorithm_type="dpmsolver++",
solver_type="midpoint",
denoise_final=True, # important if steps are <= 10
)
self.pipe = diffusers.StableDiffusionPipeline.from_pretrained(
cache_path, scheduler=scheduler
).to("cuda")
self.pipe.enable_xformers_memory_efficient_attention()
with torch.device("cuda"):
scheduler = diffusers.DPMSolverMultistepScheduler.from_pretrained(
cache_path,
subfolder="scheduler",
solver_order=2,
prediction_type="epsilon",
thresholding=False,
algorithm_type="dpmsolver++",
solver_type="midpoint",
denoise_final=True, # important if steps are <= 10
)
self.pipe = diffusers.StableDiffusionPipeline.from_pretrained(
cache_path, scheduler=scheduler
).to("cuda")
self.pipe.enable_xformers_memory_efficient_attention()

@stub.function(gpu="A10G")
def run_inference(
Expand Down