# Additional Environment Configuration for ZeroGPU Add this to your Hugging Face Space's **Settings** → **Variables**: ## Environment Variables ### Required: ``` ZEROGPU_OFFLOAD_DIR=/tmp/zerogpu-offload ``` ### Recommended: ``` PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True CUDA_LAUNCH_BLOCKING=0 HF_HUB_ENABLE_HF_TRANSFER=1 ``` ## Alternative: Direct Folder Creation If the above doesn't work, you can also try creating a startup script in your Space. ## Space Configuration File Create or modify your Space's `README.md` to include: ```yaml --- title: Wan2.2-Fast-I2I emoji: 💻 colorFrom: purple colorTo: gray sdk: gradio sdk_version: 5.44.1 app_file: app.py pinned: false hardware: a10g-large ``` The `hardware: a10g-large` ensures you get a ZeroGPU instance with sufficient memory. ## Dockerfile Alternative If you need more control, create a `Dockerfile`: ```dockerfile FROM python:3.10 # Create offload directory RUN mkdir -p /data-nvme/zerogpu-offload && chmod 755 /data-nvme/zerogpu-offload # Set environment variables ENV ZEROGPU_OFFLOAD_DIR=/data-nvme/zerogpu-offload ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True # Install your requirements COPY requirements.txt . RUN pip install -r requirements.txt # Copy your app COPY . /app WORKDIR /app CMD ["python", "app.py"] ``` ## Testing the Fix The modifications I made to `app.py` should handle: 1. ✅ **Automatic directory creation** - Creates `/data-nvme/zerogpu-offload` or falls back to `/tmp/zerogpu-offload` 2. ✅ **Permission handling** - Gracefully handles cases where NVMe isn't writable 3. ✅ **Environment variables** - Sets proper PyTorch memory configuration 4. ✅ **ZeroGPU decorators restored** - Keeps `@spaces.GPU()` for proper GPU allocation 5. ✅ **Memory optimization** - Added garbage collection and CUDA cache clearing The error should be resolved and your Space should run on ZeroGPU infrastructure properly.