File size: 3,335 Bytes
55ddab3 |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "55f9ccf6-d430-4c0a-aa60-12d8d4425c60",
"metadata": {},
"outputs": [],
"source": [
"!nvidia-smi"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8370ded1-4832-46b6-944f-235c032673b5",
"metadata": {},
"outputs": [],
"source": [
"from huggingface_hub import notebook_login\n",
"\n",
"notebook_login()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "25f44308-a145-4af2-8fd2-81dc50eaf472",
"metadata": {},
"outputs": [],
"source": [
"# Check the dataset\n",
"from datasets import load_dataset\n",
"ds = load_dataset(\"hdparmar/irish-traditional-tunes\", split=\"train\")\n",
"sample = ds[0]\n",
"display(sample[\"image\"])\n",
"print(sample[\"text\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eac20890-d221-449f-9cd6-a71c9099bff5",
"metadata": {},
"outputs": [],
"source": [
"from huggingface_hub import hf_hub_download\n",
"ckpt_path = hf_hub_download(repo_id=\"riffusion/riffusion-model-v1\", filename=\"riffusion-model-v1.ckpt\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "985a83ee-43d4-4d95-8904-4a601d3a8bca",
"metadata": {},
"outputs": [],
"source": [
"# 2xA6000:\n",
"BATCH_SIZE = 4\n",
"N_GPUS = 2\n",
"ACCUMULATE_BATCHES = 2\n",
"GPU_LIST = \",\".join((str(x) for x in range(N_GPUS))) + \",\"\n",
"print(f\"Using GPUs: {GPU_LIST}\")\n",
"\n",
"import os\n",
"os.environ[\"BATCH_SIZE\"] = str(BATCH_SIZE) \n",
"os.environ[\"N_GPUS\"] = str(N_GPUS) \n",
"os.environ[\"ACCUMULATE_BATCHES\"] = str(ACCUMULATE_BATCHES)\n",
"os.environ[\"GPU_LIST\"] = GPU_LIST\n",
"os.environ[\"CKPT_PATH\"] = ckpt_path\n",
"\n",
"!echo \"$BATCH_SIZE\"\n",
"!echo \"$N_GPUS\"\n",
"!echo \"$ACCUMULATE_BATCHES\"\n",
"!echo \"$GPU_LIST\"\n",
"!echo \"$CKPT_PATH\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64d80dca-e7c6-438f-965c-3322d0cb33ed",
"metadata": {},
"outputs": [],
"source": [
"# Run training\n",
"!(python main.py \\\n",
" -t \\\n",
" --base configs/stable-diffusion/pokemon.yaml \\\n",
" --gpus \"$GPU_LIST\" \\\n",
" --scale_lr False \\\n",
" --num_nodes 1 \\\n",
" --check_val_every_n_epoch 6 \\\n",
" --finetune_from \"$CKPT_PATH\" \\\n",
" data.params.batch_size=\"$BATCH_SIZE\" \\\n",
" lightning.trainer.accumulate_grad_batches=\"$ACCUMULATE_BATCHES\" \\\n",
" data.params.validation.params.n_gpus=\"$N_GPUS\" \\\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "438dd0c2-674b-408e-b8d6-8b789dfcd2ee",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|