File size: 5,623 Bytes
15d68eb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | # Local Dev Setup β Indic Heritage Studio v2 (NVIDIA 8Γ80GB Dev Box)
This guide walks you through setting up Indic Heritage Studio v2 on the 8 Γ NVIDIA 80GB dev box. The same code runs on AMD Radeon Cloud for the final demo β only the PyTorch wheel differs.
## Prerequisites
- **OS:** Ubuntu 22.04 LTS (or compatible)
- **Python:** 3.11
- **NVIDIA driver:** 535+ (CUDA 12.1 compatible)
- **Disk:** 50 GB free (35 GB for models, 5 GB for datasets, 10 GB for outputs)
- **RAM:** 32 GB minimum, 64 GB recommended (for LoRA training)
- **GPUs:** 8 Γ A100/H100 80GB (this is the dev target; the code also runs on 1+ GPUs)
## Step 1 β Clone
```bash
git clone https://github.com/<your-handle>/Radeon-hackathon-2026-07.git
cd Radeon-hackathon-2026-07/indic-heritage-studio-v2
```
## Step 2 β Python environment
```bash
# Install Python 3.11 if not already
sudo apt install python3.11 python3.11-venv python3.11-dev
# Create venv
python3.11 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip wheel
```
## Step 3 β Install PyTorch (CUDA 12.1)
The dev box has CUDA 12.x drivers, so we use the cu121 wheel:
```bash
pip install torch==2.4.1 torchvision==0.19.1 --index-url https://download.pytorch.org/whl/cu121
```
Verify:
```bash
python -c "
import torch
print('PyTorch:', torch.__version__)
print('CUDA available:', torch.cuda.is_available())
print('GPU count:', torch.cuda.device_count())
for i in range(torch.cuda.device_count()):
print(f' GPU {i}: {torch.cuda.get_device_name(i)} '
f'({torch.cuda.get_device_properties(i).total_memory / 1e9:.1f} GB)')
"
```
You should see 8 GPUs, each reporting ~80 GB.
## Step 4 β Install project deps
```bash
pip install -r requirements.txt
```
This installs: diffusers 0.30, transformers 4.44, accelerate, peft (LoRA), controlnet-aux, compel, gradio, openai, bitsandbytes (8-bit optimizer for LoRA training), datasets, wandb, and more.
## Step 5 β Configure environment
```bash
cp .env.example .env
```
Edit `.env`:
- `AMD_MODEL_API_KEY=<your key>` β get one free at https://developer.amd.com.cn/radeon/modelapis (used by the optional agent layer)
- Leave everything else at defaults
## Step 6 β Download models (~35 GB, ~10 min on fast connection)
```bash
python scripts/download_models.py
```
Downloads:
- SDXL 1.0 base + DreamShaper-XL turbo (~7 GB)
- SDXL refiner (~6 GB)
- SDXL inpainting checkpoint (~6 GB)
- IP-Adapter XL + image encoder (~3 GB)
- Stable Video Diffusion XT 1.1 (~10 GB)
- ControlNet Canny / Depth / OpenPose SDXL (~3 GB)
- controlnet-aux Annotators (~1 GB)
## Step 7 β Verify
```bash
python scripts/verify_rocm.py
```
Should report:
- 8 GPUs visible
- ~640 GB total VRAM
- All library versions installed
- "Multi-GPU mode: pipelines will be pinned to dedicated GPUs"
## Step 8 β Source heritage art datasets
For each of the 5 heritage styles, source 30-50 high-quality reference images:
```bash
mkdir -p assets/datasets/raw/{madhubani,warli,pattachitra,mughal,tanjore}
# Place JPG/PNG files in each subdirectory
```
See `assets/styles/README.md` for source recommendations (Wikipedia Commons, museum archives, etc.).
## Step 9 β Prepare datasets + train LoRAs
```bash
# Prepare (resize, caption, write metadata) β ~5 min
python training/prepare_dataset.py
# Train LoRA for each style β ~30 min per style on 1 GPU
python -m training.train_lora --style madhubani --steps 800
python -m training.train_lora --style warli --steps 800
python -m training.train_lora --style pattachitra --steps 800
python -m training.train_lora --style mughal --steps 800
python -m training.train_lora --style tanjore --steps 800
```
Or train all 5 in parallel across 5 GPUs:
```bash
for style in madhubani warli pattachitra mughal tanjore; do
CUDA_VISIBLE_DEVICES=$((i++)) python -m training.train_lora --style $style --steps 800 &
done
wait
```
Each LoRA saves to `assets/loras/<style>.safetensors` (~150 MB).
## Step 10 β Place IP-Adapter reference images
For each style, place one canonical reference image in `assets/styles/`:
| File | Style |
|---|---|
| `madhubani_ref.png` | Madhubani |
| `warli_ref.png` | Warli |
| `pattachitra_ref.png` | Pattachitra |
| `mughal_ref.png` | Mughal |
| `tanjore_ref.png` | Tanjore |
These are used by the IP-Adapter XL style transfer pipeline as conditioning inputs. Recommended: 1024Γ1024 RGB PNG.
## Step 11 β Run smoke tests
```bash
pytest tests/test_agents.py -v
```
Should pass all 9 tests (config, styles, agents, gpu_utils, image_utils, batch).
## Step 12 β Launch the UI
```bash
python app.py
```
Open http://localhost:7860 in your browser. You should see the 6-tab UI with the GPU monitor sidebar showing 8 GPUs.
## Step 13 β Generate demo gallery (optional, for PDF/PPT)
```bash
python scripts/generate_demo_outputs.py
```
Produces ~62 demo outputs in `examples/` (~30 min on 8Γ80GB).
## Troubleshooting
| Issue | Fix |
|---|---|
| `torch.cuda.is_available() == False` | Reinstall PyTorch with `--index-url https://download.pytorch.org/whl/cu121` |
| `RuntimeError: CUDA out of memory` during LoRA training | Lower `--batch-size` or reduce `--rank` from 32 β 16 |
| `controlnet_aux` download fails | Manually run: `python -c "from controlnet_aux import CannyDetector; CannyDetector.from_pretrained('lllyasviel/Annotators')"` |
| SVD generates black frames | Increase `noise_aug_strength` from 0.02 β 0.05 |
| Multi-GPU batch workers fail to spawn | Set `MULTI_GPU=0` in `.env` and rerun in single-GPU mode |
| Gradio UI loads but pipelines fail | Check `outputs/*.log` β most likely a missing model download |
|