Spaces:
Sleeping
Sleeping
| import time | |
| from io import BytesIO | |
| from pathlib import Path | |
| import modal | |
| cuda_version = "12.4.0" # should be no greater than host CUDA version | |
| flavor = "devel" # includes full CUDA toolkit | |
| operating_sys = "ubuntu22.04" | |
| tag = f"{cuda_version}-{flavor}-{operating_sys}" | |
| cuda_dev_image = modal.Image.from_registry( | |
| f"nvidia/cuda:{tag}", add_python="3.11" | |
| ).entrypoint([]) | |
| diffusers_commit_sha = "81cf3b2f155f1de322079af28f625349ee21ec6b" | |
| flux_image = ( | |
| cuda_dev_image.apt_install( | |
| "git", | |
| "libglib2.0-0", | |
| "libsm6", | |
| "libxrender1", | |
| "libxext6", | |
| "ffmpeg", | |
| "libgl1", | |
| ) | |
| .pip_install( | |
| "invisible_watermark==0.2.0", | |
| "transformers==4.44.0", | |
| "huggingface_hub[hf_transfer]==0.26.2", | |
| "accelerate==0.33.0", | |
| "safetensors==0.4.4", | |
| "sentencepiece==0.2.0", | |
| "torch==2.5.0", | |
| f"git+https://github.com/huggingface/diffusers.git@{diffusers_commit_sha}", | |
| "numpy<2", | |
| ) | |
| .env({"HF_HUB_ENABLE_HF_TRANSFER": "1", "HF_HUB_CACHE_DIR": "/cache"}) | |
| ) | |
| flux_image = flux_image.env( | |
| { | |
| "TORCHINDUCTOR_CACHE_DIR": "/root/.inductor-cache", | |
| "TORCHINDUCTOR_FX_GRAPH_CACHE": "1", | |
| } | |
| ) | |
| app = modal.App("example-flux", image=flux_image) | |
| with flux_image.imports(): | |
| import torch | |
| from diffusers import FluxPipeline | |