-
-
Notifications
You must be signed in to change notification settings - Fork 279
Move to a pixi-based installation
#1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 24 commits
5dd139e
0b1c4c1
e2b5664
46d7833
6634864
b41658e
12b7309
f7cb8c6
b9c4bd6
0bffc86
2c24690
9426b27
00f6d52
e76e790
6fc0455
0f7a373
e6b83c3
101cc26
b897bcc
fbeec51
1c50e81
c040fb9
afe6b42
fbc6991
aa28f0b
f582cbb
0403b1e
ea54713
543d410
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| * text=auto eol=lf | ||
| *.bat text eol=crlf | ||
| pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this line why I don't get a diff for the when I make changes, I usually want to see what I did before I commit or push. Currently I can't. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,9 +34,9 @@ OneTrainer is a one-stop solution for all your Diffusion training needs. | |
| ## Installation | ||
|
|
||
| > [!IMPORTANT] | ||
| > Installing OneTrainer requires Python >=3.10 and <3.14. | ||
| > Installing OneTrainer manually requires Python >=3.10 and <3.14. | ||
| > You can download Python at https://www.python.org/downloads/windows/. | ||
| > Then follow the below steps. | ||
| > Then follow the below manual steps. | ||
|
|
||
| #### Automatic installation | ||
|
|
||
|
|
@@ -47,23 +47,12 @@ OneTrainer is a one-stop solution for all your Diffusion training needs. | |
|
|
||
| #### Manual installation | ||
|
|
||
| 1. Clone the repository `git clone https://github.com/Nerogar/OneTrainer.git` | ||
| 2. Navigate into the cloned directory `cd OneTrainer` | ||
| 3. Set up a virtual environment `python -m venv venv` | ||
| 4. Activate the new venv: | ||
| - Windows: `venv\scripts\activate` | ||
| - Linux and Mac: Depends on your shell, activate the venv accordingly | ||
| 5. Install the requirements `pip install -r requirements.txt` | ||
|
|
||
| > [!Tip] | ||
| > Some Linux distributions are missing required packages for instance: On Ubuntu you must install `libGL`: | ||
| > | ||
| > ```bash | ||
| > sudo apt-get update | ||
| > sudo apt-get install libgl1 | ||
| > ``` | ||
| > | ||
| > Additionally it's been reported Alpine, Arch and Xubuntu Linux may be missing `tkinter`. Install it via `apk add py3-tk` for Alpine and `sudo pacman -S tk` for Arch. | ||
| 1. Install `pixi`: [Guide](https://pixi.prefix.dev/latest/installation/) | ||
| 2. Clone the repository `git clone https://github.com/Nerogar/OneTrainer.git` | ||
| 3. Navigate into the cloned directory `cd OneTrainer` | ||
| 4. Perform the installation: `pixi install --locked -e cuda` (Replace `cuda` by `rocm` or `cpu` if needed). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. manual installation with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming you merged branches and forgot to sync the git deps in requirements-global.txt and pyproject.toml. This is duplication, yes, but it's needed to keep pip and Pixi installs working.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I just followed these steps: https://github.com/nerogar/OneTrainer#manual-installation |
||
|
|
||
| **Note:** We don't support ROCm on Windows currently. | ||
|
dxqb marked this conversation as resolved.
|
||
|
|
||
| ## Updating | ||
|
|
||
|
|
@@ -75,8 +64,7 @@ OneTrainer is a one-stop solution for all your Diffusion training needs. | |
|
|
||
| 1. Cd to folder containing the repo `cd OneTrainer` | ||
| 2. Pull changes `git pull` | ||
| 3. Activate the venv `venv/scripts/activate` | ||
| 4. Re-install all requirements `pip install -r requirements.txt --force-reinstall` | ||
| 3. Recreate the environment `pixi install --locked -e cuda` | ||
|
|
||
| ## Usage | ||
|
|
||
|
|
@@ -96,7 +84,7 @@ For a technically focused quick start, see the [Quick Start Guide](docs/QuickSta | |
|
|
||
| ### CLI Mode | ||
|
|
||
| If you need more control or a headless approach OT also supports the command-line interface. All commands **need** to be run inside the active venv created during installation. | ||
| If you need more control or a headless approach OT also supports the command-line interface. All commands **need** to be run inside the active pixi environment created during installation. | ||
|
|
||
| All functionality is split into different scripts located in the `scripts` directory. This currently includes: | ||
|
|
||
|
|
@@ -111,9 +99,17 @@ All functionality is split into different scripts located in the `scripts` direc | |
| - `generate_masks.py` A utility to automatically create masks for your dataset | ||
| - `calculate_loss.py` A utility to calculate the training loss of every image in your dataset | ||
|
|
||
| To learn more about the different parameters, execute `<script-name> -h`. For example `python scripts\train.py -h` | ||
| To learn more about the different parameters, execute `./run-cmd.sh <script-name> -h`. For example `./run-cmd.sh scripts/train.py -h`. On Windows, you can do `./run-cmd.ps1 <script-name> -h`. An example of running training scripts on Windows is: | ||
|
|
||
| ```sh | ||
| ./run-cmd.ps1 train --config-path ./config.json | ||
| ``` | ||
|
|
||
| You can also activate a shell, you'd select your gpu env (usually `cuda`: https://pixi.prefix.dev/latest/advanced/pixi_shell/ | ||
|
|
||
| If you are on Mac or Linux, you can also read [the launch script documentation](LAUNCH-SCRIPTS.md) for detailed information about how to run OneTrainer and its various scripts on your system. Windows users are to refer lib.include.ps1, it mostly mirrors linux launch scripts. | ||
|
|
||
|
|
||
| If you are on Mac or Linux, you can also read [the launch script documentation](LAUNCH-SCRIPTS.md) for detailed information about how to run OneTrainer and its various scripts on your system. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
|
|
@@ -143,9 +139,7 @@ You also **NEED** to **install the required developer dependencies** for your cu | |
| > Be sure to run those commands _without activating your venv or Conda environment_, since [pre-commit](https://pre-commit.com/) is supposed to be installed outside any environment. | ||
|
|
||
| ```sh | ||
| cd OneTrainer | ||
| pip install -r requirements-dev.txt | ||
| pre-commit install | ||
| pixi global install pre-commit | ||
| ``` | ||
|
|
||
| Now all of your commits will automatically be verified for common errors and code style issues, so that code reviewers can focus on the architecture of your changes without wasting time on style/formatting issues, thus greatly improving the chances that your pull request will be accepted quickly and effortlessly. | ||
|
|
||
|
hameerabbasi marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Setup ssh | ||
| setup_ssh() { | ||
| if [[ $PUBLIC_KEY ]]; then | ||
| echo "Setting up SSH..." | ||
| mkdir -p ~/.ssh | ||
| echo "$PUBLIC_KEY" >> ~/.ssh/authorized_keys | ||
| chmod 700 -R ~/.ssh | ||
|
|
||
| if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then | ||
| ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -q -N '' | ||
| echo "RSA key fingerprint:" | ||
| ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub | ||
| fi | ||
|
|
||
| if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then | ||
| ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -q -N '' | ||
| echo "DSA key fingerprint:" | ||
| ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub | ||
| fi | ||
|
|
||
| if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then | ||
| ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -q -N '' | ||
| echo "ECDSA key fingerprint:" | ||
| ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub | ||
| fi | ||
|
|
||
| if [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then | ||
| ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -q -N '' | ||
| echo "ED25519 key fingerprint:" | ||
| ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub | ||
| fi | ||
|
|
||
| service ssh start | ||
|
|
||
| echo "SSH host keys:" | ||
| for key in /etc/ssh/*.pub; do | ||
| echo "Key: $key" | ||
| ssh-keygen -lf $key | ||
| done | ||
| fi | ||
| } | ||
|
|
||
| setup_ssh | ||
| service ssh start | ||
| sleep infinity |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,7 @@ | ||
| @echo off | ||
|
|
||
| REM Avoid footgun by explictly navigating to the directory containing the batch file | ||
| chcp 65001 >nul | ||
| cd /d "%~dp0" | ||
|
|
||
| REM Verify that OneTrainer is our current working directory | ||
| if not exist "scripts\train_ui.py" ( | ||
| echo Error: train_ui.py does not exist, you have done something very wrong. Reclone the repository. | ||
| goto :end | ||
| ) | ||
|
|
||
| if not defined PYTHON (set PYTHON=python) | ||
| if not defined VENV_DIR (set "VENV_DIR=%~dp0venv") | ||
|
|
||
| :check_venv | ||
| dir "%VENV_DIR%" >NUL 2>NUL | ||
| if not errorlevel 1 goto :activate_venv | ||
| echo venv not found, please run install.bat first | ||
| goto :end | ||
|
|
||
| :activate_venv | ||
| echo activating venv %VENV_DIR% | ||
| set PYTHON="%VENV_DIR%\Scripts\python.exe" -X utf8 | ||
| echo Using Python %PYTHON% | ||
|
|
||
| :launch | ||
| echo Generating debug report... | ||
| %PYTHON% scripts\generate_debug_report.py | ||
| if errorlevel 1 ( | ||
| echo Error: Debug report generation failed with code %ERRORLEVEL% | ||
| ) else ( | ||
| echo Now upload the debug report to your Github issue or post in Discord. | ||
| ) | ||
|
|
||
| :end | ||
| powershell -ExecutionPolicy Bypass -File "%~dp0scripts\powershell\export_debug.ps1" %* | ||
| set "_EXIT=%ERRORLEVEL%" | ||
| pause | ||
| exit /b %_EXIT% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
the Dockerfiles start from a base image and then install OneTrainer in there. never is the local repository used.
why shouldn't the image have a
.gitignorefile?Someone might develop inside docker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mainly to not add .pixi, as that will be generated on the build itself. I can change this if needed, but the overall goal was to keep the dockerfile as small as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh! This is a symlink, so both ignore files are kept in sync, and we don't have to sync both.