forked from Nerogar/OneTrainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-ui.sh
executable file
·62 lines (57 loc) · 2.33 KB
/
start-ui.sh
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
#!/bin/bash
#change the environment name for conda to use
conda_env=ot
#change the environment name for python to use (only needed if Anaconda3 or miniconda is not installed)
python_venv=venv
#additional arguments helpful if running into CUDA OOM error; default: false
use_alloc_args=false
if [ "$(uname)" = "Darwin" ]; then
export PYTORCH_ENABLE_MPS_FALLBACK=1
fi
if "$use_alloc_args"; then
export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:128
fi
if ! [ -x "$(command -v python)" ]; then
echo 'error: python not installed or found!'
break
elif [ -x "$(command -v python)" ]; then
major=$(python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major)')
minor=$(python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(minor)')
#check major version of python
if [[ "$major" -eq "3" ]];
then
#check minor version of python
if [[ "$minor" -le "10" || "$minor" -le "11" ]];
then
if ! [ -x "$(command -v conda)" ]; then
echo 'conda not found; python version correct; use native python'
if ! [ -d $python_venv ]; then
python -m venv $python_venv
fi
source $python_venv/bin/activate
if [[ -z "$VIRTUAL_ENV" ]]; then
echo "warning: No VIRTUAL_ENV set. exiting."
else
python scripts/train_ui.py
fi
elif [ -x "$(command -v conda)" ]; then
#check for venv
if conda info --envs | grep -q ${conda_env};
then
bash --init-file <(echo ". \"$HOME/.bashrc\"; conda activate $conda_env; python scripts/train_ui.py")
else
conda create -y -n $conda_env python==3.10;
bash --init-file <(echo ". \"$HOME/.bashrc\"; conda activate $conda_env; python scripts/train_ui.py")
fi
fi
else
echo 'error: wrong python version installed:'$major'.'$minor
echo 'OneTrainer requires the use of python 3.10, please refer to the anaconda project to setup a virtual environment with that version. https://anaconda.org/anaconda/python'
exit 1
fi
else
echo 'error: wrong python version installed:'$major'.'$minor
echo 'OneTrainer requires the use of python 3.10, either install python3 on your system or refer to the anaconda project to setup a virtual environment with that version. https://anaconda.org/anaconda/python'
exit 1
fi
fi