Last active
November 26, 2024 12:48
-
-
Save leinad13/23290a349d04f9b1ca9c81541793e415 to your computer and use it in GitHub Desktop.
OneTrainer Provisioning Script (Flux)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vast.ai aidock linux-desktop image | |
# set ENV VAR | |
# save stdout and stderr to file | |
# descriptors 3 and 4, | |
# then redirect them to "foo" | |
# exec 3>&1 4>&2 >/workspace/prov.log 2>&1 | |
exec 3>&1 4>&2 >/var/log/provisioning.log 2>&1 | |
echo "Starting OneTrainer Provisioning Script (Flux)..." | |
sudo apt install python-is-python3 && echo "########### Set Python3 as Python" || (echo "########### Failed to Set Python3 as Python" && exit) | |
sudo apt-get -y install cudnn9-cuda-12 && echo "########### Installed cudnn9-cuda-12" || (echo "########### Failed to Install cudnn9-cuda-12" && exit) | |
# Download and Install nvitop | |
mkdir /workspace/nvitop && cd /workspace/nvitop | |
python -m venv env | |
source /workspace/nvitop/env/bin/activate | |
pip3 install --upgrade nvitop | |
# Create nvitop.sh | |
cat >nvitop.sh <<EOF | |
#!/bin/bash | |
source /workspace/nvitop/env/bin/activate | |
nvitop | |
EOF | |
sudo chmod +x nvitop.sh | |
# Create desktop shortcut | |
cat >~/Desktop/nvitop <<EOF | |
#!/usr/bin/env xdg-open | |
[Desktop Entry] | |
Type=Application | |
Name=nvitop | |
Exec=/bin/bash /workspace/nvitop/nvitop.sh | |
Terminal=true | |
EOF | |
# Download and Install OneTrainer | |
cd /workspace | |
git clone https://github.com/Nerogar/OneTrainer.git && echo "########### Cloned OneTrainer into /workspace/OneTrainer" || (echo "########### Failed to Clone OneTrainer" && exit) | |
cd /workspace/OneTrainer | |
./install.sh | |
# Download Flux Model from HuggingFace | |
source /workspace/OneTrainer/venv/bin/activate | |
mkdir /workspace/hf | |
export HF_HUB_ENABLE_HF_TRANSFER=1 | |
export HF_HOME=/workspace/hf | |
pip install huggingface_hub[hf_transfer] | |
huggingface-cli login --token $HF_TOKEN | |
huggingface-cli download black-forest-labs/FLUX.1-dev model_index.json & | |
# Set up rclone | |
curl https://rclone.org/install.sh | sudo bash | |
rclone config create b2 b2 --obscure account $B2_ACCOUNT key $B2_KEY -vv | |
mkdir /workspace/sync | |
rclone copy b2:$B2_PATH /workspace/sync -P | |
echo "########### Finished OneTrainer Provisioning Script (Flux)" | |
# restore stdout and stderr | |
exec 1>&3 2>&4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment