Hello everyone, in this article I want to tell you how you can train your LoRA for free. In total, about ~15 LoRA can be produced per month, according to my calculations
How does this work?
The whole point is based on a service called Modal, which gives you $30 a month for free so you can run anything that requires a GPU or other computing power.
Preparation
Check out this guide to creating LoRA. It describes all the basic points for training LoRA, and also includes a config file for greater convenience.
You will also need git and python installed (preferably version 3.12)
You need a dataset and a basic model on which LoRA training will take place.
And finally, you need an account on the Modal service to run it all.
Launch and training
Follow all the steps from the preparation. It is important!
Install the modal-client using pip. In the terminal running as an administrator, enter the following:
pip install modal
python -m modal setupThe browser opens and you need to log in to the service.
Copy the repository from github to your PC
git clone https://github.com/IjoiK12/modal-deploy-kohya-ss.gitNavigate to the folder and edit the config.toml file according to your needs. I recommend changing the GPU to A100 or lighter, with this option it will be possible to make more LoRA (List of available GPUs: T4, L4, A10, A100-40GB, A100-80GB, L40S, H100, H200, B200)
Open the terminal in the project folder and enter the following commands:
python -m modal volume create kohya-configs
python -m modal volume create kohya-outputs
python -m modal volume create kohya-models
python -m modal volume create kohya-datasetThese commands will create the necessary volumes, to which we will send all the files prepared in advance.
Now we actually need to send all the files prepared in advance to the server. For example, pre-prepared images (with a txt tags) in the dataset folder, configs in the configs folder, and models in the models folder. Example:
python -m modal volume put kohya-configs C:\Users\User\Downloads\SDXL_ILLUS.json /SDXL_ILLUS.json (By analogy, this must be done with other files.)
Now we need to launch the application itself using the following command:
python -m modal deploy app.pyThe first launch may take a long time (up to 15 minutes, the next launches are faster). After the successful launch, a link with the application will appear. You need to go and the app will launch (it also takes about 3 minutes and you can refresh the page to make sure you don't miss the launch)
Done. We have launched kohya_ss in the cloud and are ready to train. Good luck! To do everything right, let me remind you once again about this article.
P.S.
Do not forget to stop the containers after use, otherwise your balance can quickly become zero.
Also, if you need a video tutorial, please let us know. If possible, I'll do it.

