Skip to content

Commit

Permalink
Make xformers install command modifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
ddPn08 committed Apr 30, 2023
1 parent 818e2cd commit 6c8d70c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/en/usage/tensorrt.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--tensorrt --reinstall-torch
set TORCH_COMMAND=pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
set XFORMERS_COMMAND=pip install xformers==0.0.16
call launch.bat
```
Expand All @@ -41,6 +42,7 @@ call launch.bat
```sh
export COMMANDLINE_ARGS="--tensorrt --reinstall-torch"
export TORCH_COMMAND="pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117"
export XFORMERS_COMMAND="pip install xformers==0.0.16"
```

2. Run `launch-user.sh`
2 changes: 2 additions & 0 deletions docs/ja/usage/tensorrt.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--tensorrt --reinstall-torch
set TORCH_COMMAND=pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
set XFORMERS_COMMAND=pip install xformers==0.0.16
call launch.bat
```
Expand All @@ -42,6 +43,7 @@ call launch.bat
```sh
export COMMANDLINE_ARGS="--tensorrt --reinstall-torch"
export TORCH_COMMAND="pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117"
export XFORMERS_COMMAND="pip install xformers==0.0.16"
```

2. `launch-user.sh`を実行します
2 changes: 1 addition & 1 deletion launch-user.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=

call launch.bat
call launch.bat
16 changes: 9 additions & 7 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def prepare_environment():
"TORCH_COMMAND",
"pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118",
)
xformers_command = os.environ.get(
"XFORMERS_COMMAND",
"pip install xformers",
)

sys.argv, skip_install = extract_arg(sys.argv, "--skip-install")
if skip_install:
Expand All @@ -159,20 +163,18 @@ def prepare_environment():
tensorrt = "--tensorrt" in sys.argv

if reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
if reinstall_torch:
run(
f'"{python}" -m pip uninstall torch torchvision -y',
"Uninstalling torch and torchvision",
"Couldn't uninstall torch",
)
run(
f'"{python}" -m {torch_command}',
"Installing torch and torchvision",
"Couldn't install torch",
)

if reinstall_xformers or not is_installed("xformers"):
run_pip("install xformers", "xformers")
run(
f'"{python}" -m {xformers_command}',
"Installing xformers",
"Couldn't install xformers",
)

run(
f'"{python}" -m pip install -r requirements/base.txt',
Expand Down
3 changes: 3 additions & 0 deletions user-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# install command for torch
#export TORCH_COMMAND="pip install torch --extra-index-url https://download.pytorch.org/whl/cu118"

# install command for xformers
#export XFORMERS_COMMAND="pip install xformers"

# Requirements file to use for stable-diffusion-webui
#export REQS_FILE="requirements_versions.txt"

Expand Down

0 comments on commit 6c8d70c

Please sign in to comment.