|
1 | 1 | r"""Example for dalle-mini demo model. |
2 | 2 |
|
| 3 | +First run following command to install required packages: |
| 4 | + pip install -r ./lit_nlp/examples/dalle_mini/requirements.txt |
| 5 | +
|
3 | 6 | To run locally with a small number of examples: |
4 | 7 | python -m lit_nlp.examples.dalle_mini.demo |
5 | 8 |
|
| 9 | +By default, this module uses the "cuda" device for image generation. |
| 10 | +The `requirements.txt` file installs a CUDA-enabled version of PyTorch for GPU |
| 11 | +acceleration. |
| 12 | +
|
| 13 | +If you are running on a machine without a compatible GPU or CUDA drivers, |
| 14 | +you must switch the device to "cpu" and reinstall the CPU-only version of |
| 15 | +PyTorch. |
| 16 | +
|
| 17 | +Usage: |
| 18 | + - Default: device="cuda" |
| 19 | + - On CPU-only machines: |
| 20 | + 1. Set device="cpu" during model initialization |
| 21 | + 2. Uninstall the CUDA version of PyTorch: |
| 22 | + pip uninstall torch |
| 23 | + 3. Install the CPU-only version: |
| 24 | + pip install torch==2.1.2+cpu --extra-index-url |
| 25 | + https://download.pytorch.org/whl/cpu |
| 26 | +
|
| 27 | +Example: |
| 28 | + >>> model = MinDalle(..., device="cpu") |
| 29 | +
|
| 30 | +Check CUDA availability: |
| 31 | + >>> import torch |
| 32 | + >>> torch.cuda.is_available() |
| 33 | + False # if no GPU support is present |
| 34 | +
|
| 35 | +Error Handling: |
| 36 | + - If CUDA is selected but unsupported, you will see: |
| 37 | + AssertionError: Torch not compiled with CUDA enabled |
| 38 | + - To fix this, either install the correct CUDA-enabled PyTorch or switch to |
| 39 | + CPU mode. |
6 | 40 |
|
7 | 41 | Then navigate to localhost:5432 to access the demo UI. |
8 | 42 | """ |
|
26 | 60 | _FLAGS.set_default("development_demo", True) |
27 | 61 | _FLAGS.set_default("default_layout", "DALLE_LAYOUT") |
28 | 62 |
|
29 | | -_FLAGS.DEFINE_integer("grid_size", 4, "The grid size to use for the model.") |
30 | | - |
31 | 63 | _MODELS = (["dalle-mini"],) |
32 | 64 |
|
33 | 65 | _CANNED_PROMPTS = ["I have a dream", "I have a shiba dog named cola"] |
|
0 commit comments