carloscar commited on
Commit
57d969e
1 Parent(s): a50c640

installation

Browse files
Files changed (3) hide show
  1. Dockerfile +5 -5
  2. on_start.sh +12 -0
  3. run.py +4 -1
Dockerfile CHANGED
@@ -66,6 +66,11 @@ RUN echo "export PATH=$PATH" >> ~/.bashrc \
66
  && python3 -m venv $VIRTUAL_ENV \
67
  && /opt/venv/bin/pip install --upgrade --no-cache-dir pip
68
 
 
 
 
 
 
69
  # Installation of basic Python dependencies specified in pyproject.toml
70
  WORKDIR /app
71
  COPY pyproject.toml poetry.lock /app/
@@ -97,11 +102,6 @@ RUN sed -i -e 's/ queue=False, / /g' modules/ui.py
97
  COPY run.py on_start.sh /app/stable-diffusion-webui/
98
  RUN chmod +x on_start.sh
99
 
100
- # Run app as non-root user
101
- RUN adduser --disabled-password --gecos '' user
102
- RUN chown -R user:user /app
103
- USER user
104
-
105
  EXPOSE 7860
106
 
107
  CMD ["/opt/venv/bin/python", "run.py", "--force-enable-xformers", "--xformers", "--listen", "--enable-insecure-extension-access", "--ui-config-file", "ui-config.json", "--ui-settings-file", "config.json", "--disable-console-progressbars", "--cors-allow-origins", "huggingface.co,hf.space", "--no-progressbar-hiding", "--enable-console-prompts", "--no-download-sd-model", "--api", "--skip-version-check"]
 
66
  && python3 -m venv $VIRTUAL_ENV \
67
  && /opt/venv/bin/pip install --upgrade --no-cache-dir pip
68
 
69
+ # Run app as non-root user
70
+ RUN adduser --disabled-password --gecos '' user
71
+ RUN chown -R user:user /app /opt/venv
72
+ USER user
73
+
74
  # Installation of basic Python dependencies specified in pyproject.toml
75
  WORKDIR /app
76
  COPY pyproject.toml poetry.lock /app/
 
102
  COPY run.py on_start.sh /app/stable-diffusion-webui/
103
  RUN chmod +x on_start.sh
104
 
 
 
 
 
 
105
  EXPOSE 7860
106
 
107
  CMD ["/opt/venv/bin/python", "run.py", "--force-enable-xformers", "--xformers", "--listen", "--enable-insecure-extension-access", "--ui-config-file", "ui-config.json", "--ui-settings-file", "config.json", "--disable-console-progressbars", "--cors-allow-origins", "huggingface.co,hf.space", "--no-progressbar-hiding", "--enable-console-prompts", "--no-download-sd-model", "--api", "--skip-version-check"]
on_start.sh CHANGED
@@ -1,6 +1,18 @@
1
  #!/bin/bash
2
  set -euo pipefail
3
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # SD 2.1 768 base model
5
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/36a01dc742066de2e8c91e7cf0b8f6b53ef53da1/v2-1_768-ema-pruned.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.safetensors
6
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://raw.githubusercontent.com/Stability-AI/stablediffusion/fc1488421a2761937b9d54784194157882cbc3b1/configs/stable-diffusion/v2-inference-v.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.yaml
 
1
  #!/bin/bash
2
  set -euo pipefail
3
 
4
+ # echo "\$ nvidia smi"
5
+ # nvidia-smi
6
+ #
7
+ # # Install xformers matching the GPU (only for Nvidia A10G and T4 GPUs)
8
+ # if nvidia-smi --query-gpu=gpu_name --format=csv,noheader | grep -q A10G; then
9
+ # /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl
10
+ # elif nvidia-smi --query-gpu=gpu_name --format=csv,noheader | grep -q T4; then
11
+ # /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp310-cp310-linux_x86_64.whl
12
+ # else
13
+ # /opt/venv/bin/pip install --pre xformers
14
+ # fi
15
+
16
  # SD 2.1 768 base model
17
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/36a01dc742066de2e8c91e7cf0b8f6b53ef53da1/v2-1_768-ema-pruned.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.safetensors
18
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://raw.githubusercontent.com/Stability-AI/stablediffusion/fc1488421a2761937b9d54784194157882cbc3b1/configs/stable-diffusion/v2-inference-v.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.yaml
run.py CHANGED
@@ -4,7 +4,9 @@ import sys
4
 
5
 
6
  def on_start():
7
- print("Executing './on_start.sh' (that installs xformers, downloads models, etc.)")
 
 
8
  result = subprocess.run("./on_start.sh", shell=True, env=os.environ)
9
  if result.returncode != 0:
10
  raise RuntimeError(f"Error executing ./on_start.sh [exit code: {result.returncode}]")
@@ -15,6 +17,7 @@ def start():
15
 
16
  print("---------------")
17
  print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with arguments: {' '.join(sys.argv[1:])}")
 
18
  import webui # type: ignore # noqa
19
  if '--nowebui' in sys.argv:
20
  webui.api_only()
 
4
 
5
 
6
  def on_start():
7
+ print("---------------")
8
+ print("Executing './on_start.sh' (downloads models, etc.)")
9
+ print("---------------")
10
  result = subprocess.run("./on_start.sh", shell=True, env=os.environ)
11
  if result.returncode != 0:
12
  raise RuntimeError(f"Error executing ./on_start.sh [exit code: {result.returncode}]")
 
17
 
18
  print("---------------")
19
  print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with arguments: {' '.join(sys.argv[1:])}")
20
+ print("---------------")
21
  import webui # type: ignore # noqa
22
  if '--nowebui' in sys.argv:
23
  webui.api_only()