|
| 1 | +## Diffuse Environments |
| 2 | + |
| 3 | +Diffuse manages isolated **Python virtual environments** to ensure pipelines run with the correct dependencies for each hardware vendor, device, and pipeline type. |
| 4 | + |
| 5 | +### Why Environments Exist |
| 6 | + |
| 7 | +Different GPUs, drivers, and pipelines often require **different Python packages and versions**. |
| 8 | +Trying to run everything in one shared Python environment quickly leads to conflicts, crashes, or broken installs. |
| 9 | + |
| 10 | +Diffuse solves this by giving each setup its **own isolated environment**, so: |
| 11 | + |
| 12 | +- NVIDIA and AMD dependencies never clash |
| 13 | +- Pipelines can use exactly the versions they need |
| 14 | +- Updating or rebuilding one environment won’t break others |
| 15 | +- Experiments stay contained and predictable |
| 16 | + |
| 17 | +In short: **environments keep Diffuse stable, reproducible, and easy to recover when something goes wrong**. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +### Overview |
| 22 | + |
| 23 | +- Environments are **Python `venv`-based** |
| 24 | +- Each environment runs in an **external process** |
| 25 | +- Communication with Diffuse uses **named-pipe IPC** |
| 26 | +- Environments may define **custom environment variables** |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +### Lifecycle |
| 31 | + |
| 32 | +- An environment is **automatically launched when a pipeline is loaded** |
| 33 | +- The environment **shuts down when the pipeline is unloaded** |
| 34 | +- Environments can be **created, rebuilt, or deleted on demand** |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +### Vendor & Device Isolation |
| 39 | + |
| 40 | +All environments are **vendor-specific** (for example: NVIDIA or AMD). |
| 41 | + |
| 42 | +More granular environments can also be defined: |
| 43 | + |
| 44 | +- **Device-specific environments** |
| 45 | + _Example:_ `Vendor=AMD, Device=W7900` |
| 46 | + |
| 47 | +- **Pipeline-specific environments** |
| 48 | + _Example:_ `Vendor=AMD, Pipeline=FluxPipeline` |
| 49 | + |
| 50 | +This allows Diffuse to safely handle incompatible runtimes, drivers, and Python dependencies without conflict. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### Environment Selection & Precedence |
| 55 | + |
| 56 | +When loading a pipeline, Diffuse selects the environment using the following precedence order: |
| 57 | + |
| 58 | +1. **Pipeline-specific environment** |
| 59 | +2. **Device-specific environment** |
| 60 | +3. **Vendor-specific environment** |
| 61 | + |
| 62 | +The most specific matching environment is always chosen. |
0 commit comments