π Production-ready serverless endpoint for FLUX LoRA training on RunPod GPU pods
This template provides a complete serverless solution for training custom FLUX LoRA models using RunPod's GPU infrastructure. Optimized for 24GB VRAM with FluxGym-inspired settings and intelligent image captioning.
flux-lora-trainerServerlessDocker Hub or GitHub Container Registry101world/Ray-Train-Masterflux-runpod-template/flux-runpod-template/DockerfileSet these in your RunPod template configuration:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
S3_BUCKET_NAME=your_bucket_name
AWS_S3_ENDPOINT_URL=https://your-s3-endpoint.com
AWS_DEFAULT_REGION=us-east-1
TRAINING_STEPS=1000
LEARNING_RATE=8e-4
NETWORK_DIM=4
BATCH_SIZE=1
VRAM=24G
Recommended GPU Settings:
POST https://api.runpod.ai/v2/your-endpoint-id/runsync
Content-Type: application/json
Authorization: Bearer YOUR_RUNPOD_API_KEY
{
"input": {
"dataset_s3_key": "datasets/character-photos.zip",
"character_name": "alice_wonderland",
"trigger_word": "alice",
"config": {
"learning_rate": "8e-4",
"max_train_epochs": 16,
"network_dim": 4,
"vram": "24G"
}
}
}
{
"id": "job-12345",
"status": "COMPLETED",
"output": {
"status": "success",
"character_name": "alice_wonderland",
"trigger_word": "alice",
"image_count": 25,
"model_s3_key": "models/alice_wonderland/flux_lora_job-12345.safetensors",
"download_url": "https://presigned-url-to-download",
"job_id": "job-12345",
"training_time": 1694123456
}
}
async function trainFluxModel(apiKey, endpointId, dataset) {
const response = await fetch(`https://api.runpod.ai/v2/${endpointId}/runsync`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify({
input: {
dataset_s3_key: dataset.s3Key,
character_name: dataset.characterName,
trigger_word: dataset.triggerWord,
config: {
learning_rate: "8e-4",
max_train_epochs: 16,
network_dim: 4,
vram: "24G"
}
}
})
});
return await response.json();
}
import requests
def train_flux_model(api_key, endpoint_id, dataset_config):
url = f"https://api.runpod.ai/v2/{endpoint_id}/runsync"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
payload = {
"input": {
"dataset_s3_key": dataset_config["s3_key"],
"character_name": dataset_config["character_name"],
"trigger_word": dataset_config["trigger_word"],
"config": {
"learning_rate": "8e-4",
"max_train_epochs": 16,
"network_dim": 4,
"vram": "24G"
}
}
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
| VRAM | Optimizer | Special Settings |
|---|---|---|
| 12GB | AdaFactor | Split mode, single block training |
| 16GB | AdaFactor | Standard settings |
| 20GB+ | AdamW8bit | Full training, best quality |
| Parameter | Default | Description |
|---|---|---|
learning_rate | 8e-4 | FluxGym optimized learning rate |
network_dim | 4 | LoRA network dimension |
max_train_epochs | 16 | Maximum training epochs |
batch_size | 1 | Training batch size |
resolution | 512 | Training image resolution |
Store sensitive credentials in RunPod's secure environment variable system:
# In RunPod Dashboard -> Template -> Environment Variables
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=secret123...
S3_BUCKET_NAME=my-flux-training
Check RunPod logs for real-time training progress:
[INFO] Starting training job job-12345 for character 'alice' with trigger 'alice'
[INFO] Dataset extracted: 25 images found
[INFO] Starting FLUX LoRA training with 7200s timeout...
[INFO] Training completed successfully
[INFO] Model upload completed successfully
| Issue | Solution |
|---|---|
Training timed out | Reduce epochs or increase timeout |
CUDA out of memory | Lower VRAM setting or batch size |
S3 upload failed | Check bucket permissions and credentials |
No images found | Verify dataset ZIP contains images |
{
"status": "error",
"error": "Training timed out after 120 minutes",
"job_id": "job-12345",
"error_time": 1694123456
}
Use git tags for production deployments:
git tag v1.0.0
git push origin v1.0.0
For issues and questions:
β‘ Ready to deploy? Follow the Quick Deployment section above to get your FLUX LoRA training endpoint running in minutes!
23 commits
Python
96.8%
Dockerfile
2.4%
π Production-ready serverless endpoint for FLUX LoRA training on RunPod GPU pods
This template provides a complete serverless solution for training custom FLUX LoRA models using RunPod's GPU infrastructure. Optimized for 24GB VRAM with FluxGym-inspired settings and intelligent image captioning.
flux-lora-trainerServerlessDocker Hub or GitHub Container Registry101world/Ray-Train-Masterflux-runpod-template/flux-runpod-template/DockerfileSet these in your RunPod template configuration:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
S3_BUCKET_NAME=your_bucket_name
AWS_S3_ENDPOINT_URL=https://your-s3-endpoint.com
AWS_DEFAULT_REGION=us-east-1
TRAINING_STEPS=1000
LEARNING_RATE=8e-4
NETWORK_DIM=4
BATCH_SIZE=1
VRAM=24G
Recommended GPU Settings:
POST https://api.runpod.ai/v2/your-endpoint-id/runsync
Content-Type: application/json
Authorization: Bearer YOUR_RUNPOD_API_KEY
{
"input": {
"dataset_s3_key": "datasets/character-photos.zip",
"character_name": "alice_wonderland",
"trigger_word": "alice",
"config": {
"learning_rate": "8e-4",
"max_train_epochs": 16,
"network_dim": 4,
"vram": "24G"
}
}
}
{
"id": "job-12345",
"status": "COMPLETED",
"output": {
"status": "success",
"character_name": "alice_wonderland",
"trigger_word": "alice",
"image_count": 25,
"model_s3_key": "models/alice_wonderland/flux_lora_job-12345.safetensors",
"download_url": "https://presigned-url-to-download",
"job_id": "job-12345",
"training_time": 1694123456
}
}
async function trainFluxModel(apiKey, endpointId, dataset) {
const response = await fetch(`https://api.runpod.ai/v2/${endpointId}/runsync`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify({
input: {
dataset_s3_key: dataset.s3Key,
character_name: dataset.characterName,
trigger_word: dataset.triggerWord,
config: {
learning_rate: "8e-4",
max_train_epochs: 16,
network_dim: 4,
vram: "24G"
}
}
})
});
return await response.json();
}
import requests
def train_flux_model(api_key, endpoint_id, dataset_config):
url = f"https://api.runpod.ai/v2/{endpoint_id}/runsync"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
payload = {
"input": {
"dataset_s3_key": dataset_config["s3_key"],
"character_name": dataset_config["character_name"],
"trigger_word": dataset_config["trigger_word"],
"config": {
"learning_rate": "8e-4",
"max_train_epochs": 16,
"network_dim": 4,
"vram": "24G"
}
}
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
| VRAM | Optimizer | Special Settings |
|---|---|---|
| 12GB | AdaFactor | Split mode, single block training |
| 16GB | AdaFactor | Standard settings |
| 20GB+ | AdamW8bit | Full training, best quality |
| Parameter | Default | Description |
|---|---|---|
learning_rate | 8e-4 | FluxGym optimized learning rate |
network_dim | 4 | LoRA network dimension |
max_train_epochs | 16 | Maximum training epochs |
batch_size | 1 | Training batch size |
resolution | 512 | Training image resolution |
Store sensitive credentials in RunPod's secure environment variable system:
# In RunPod Dashboard -> Template -> Environment Variables
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=secret123...
S3_BUCKET_NAME=my-flux-training
Check RunPod logs for real-time training progress:
[INFO] Starting training job job-12345 for character 'alice' with trigger 'alice'
[INFO] Dataset extracted: 25 images found
[INFO] Starting FLUX LoRA training with 7200s timeout...
[INFO] Training completed successfully
[INFO] Model upload completed successfully
| Issue | Solution |
|---|---|
Training timed out | Reduce epochs or increase timeout |
CUDA out of memory | Lower VRAM setting or batch size |
S3 upload failed | Check bucket permissions and credentials |
No images found | Verify dataset ZIP contains images |
{
"status": "error",
"error": "Training timed out after 120 minutes",
"job_id": "job-12345",
"error_time": 1694123456
}
Use git tags for production deployments:
git tag v1.0.0
git push origin v1.0.0
For issues and questions:
β‘ Ready to deploy? Follow the Quick Deployment section above to get your FLUX LoRA training endpoint running in minutes!
23 commits
Python
96.8%
Dockerfile
2.4%