Building xformers from source
Browse files
app.py
CHANGED
|
@@ -4,11 +4,6 @@ from subprocess import getoutput
|
|
| 4 |
# Welcome to the world of python madness!
|
| 5 |
|
| 6 |
# Debugging with Verbose mode on...
|
| 7 |
-
os.system('echo "Creating virtual environment..."')
|
| 8 |
-
os.system('python -m venv /home/user/app/venv')
|
| 9 |
-
os.system('source /home/user/app/venv/bin/activate')
|
| 10 |
-
|
| 11 |
-
|
| 12 |
os.system(f'echo "Checking Python Version"')
|
| 13 |
os.system(f"python --version")
|
| 14 |
|
|
@@ -23,9 +18,9 @@ os.system(f'echo "Setting working directory to stable-diffusion-webui root folde
|
|
| 23 |
os.chdir("/home/user/app/stable-diffusion-webui")
|
| 24 |
|
| 25 |
# clean requirements.txt
|
| 26 |
-
os.system(f'echo "Removing numpy and torch from requirements.txt to prevent version conflicts..."')
|
| 27 |
-
os.system(f"sed -i '/numpy/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 28 |
-
os.system(f"sed -i '/torch/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 29 |
|
| 30 |
# Patch environment
|
| 31 |
os.system(f'echo "Downloading environment patch script..."')
|
|
@@ -33,17 +28,17 @@ os.system(f"wget https://github.com/camenduru/webui/raw/main/env_patch.py -O /h
|
|
| 33 |
os.system(f"sed -i -e '/import image_from_url_text/r /home/user/app/env_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 34 |
|
| 35 |
# UI customization
|
| 36 |
-
os.system(f'echo "Removing Checkpoint Merger tab from UI..."')
|
| 37 |
-
os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 38 |
|
| 39 |
-
os.system(f'echo "Removing Training tab from UI..."')
|
| 40 |
-
os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 41 |
|
| 42 |
-
os.system(f'echo "Removing Extensions tab from UI..."')
|
| 43 |
-
os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 44 |
|
| 45 |
-
os.system(f'echo "Removing Settings tab from UI..."')
|
| 46 |
-
os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 47 |
|
| 48 |
# Gradio shadowRoot fix
|
| 49 |
os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."')
|
|
@@ -108,26 +103,34 @@ else:
|
|
| 108 |
os.system(f"wget -q https://huggingface.co/darkstorm2150/Protogen_x3.4_Official_Release/resolve/main/ProtoGen_X3.4.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/ProtoGen_X3.4.safetensors")
|
| 109 |
|
| 110 |
# Critical dependency installation sequence
|
| 111 |
-
os.system(f'echo "starting dependency cleanup..."')
|
| 112 |
-
os.system(f'pip cache purge')
|
| 113 |
|
| 114 |
# Running multiple times to remove stubborn copies
|
| 115 |
-
os.system(f'echo "Removing all existing numpy versions..."')
|
| 116 |
-
os.system(f'pip uninstall -y numpy numpy numpy')
|
| 117 |
|
| 118 |
# Force NumPy 1.26.4 first
|
| 119 |
-
os.system(f'echo "Installing NumPy 1.26.4..."')
|
| 120 |
-
os.system(f"pip install --no-cache-dir numpy==1.26.4")
|
| 121 |
|
| 122 |
# Verify NumPy Version 1.26.4
|
| 123 |
-
os.system(f"python -c 'import numpy; print(numpy.__version__)'")
|
| 124 |
|
| 125 |
# Install PyTorch + xformers with CUDA compatibility
|
| 126 |
-
os.system(f'echo "Installing PyTorch..."')
|
| 127 |
-
os.system(f"pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121 ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
os.system(f'echo "Installing xformers..."')
|
| 130 |
-
os.
|
|
|
|
| 131 |
|
| 132 |
# Final verification
|
| 133 |
os.system(f'echo "Verifying NumPy, PyTorch, and xformers versions..."')
|
|
|
|
| 4 |
# Welcome to the world of python madness!
|
| 5 |
|
| 6 |
# Debugging with Verbose mode on...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
os.system(f'echo "Checking Python Version"')
|
| 8 |
os.system(f"python --version")
|
| 9 |
|
|
|
|
| 18 |
os.chdir("/home/user/app/stable-diffusion-webui")
|
| 19 |
|
| 20 |
# clean requirements.txt
|
| 21 |
+
#os.system(f'echo "Removing numpy and torch from requirements.txt to prevent version conflicts..."')
|
| 22 |
+
#os.system(f"sed -i '/numpy/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 23 |
+
#os.system(f"sed -i '/torch/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 24 |
|
| 25 |
# Patch environment
|
| 26 |
os.system(f'echo "Downloading environment patch script..."')
|
|
|
|
| 28 |
os.system(f"sed -i -e '/import image_from_url_text/r /home/user/app/env_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 29 |
|
| 30 |
# UI customization
|
| 31 |
+
#os.system(f'echo "Removing Checkpoint Merger tab from UI..."')
|
| 32 |
+
#os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 33 |
|
| 34 |
+
#os.system(f'echo "Removing Training tab from UI..."')
|
| 35 |
+
#os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 36 |
|
| 37 |
+
#os.system(f'echo "Removing Extensions tab from UI..."')
|
| 38 |
+
#os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 39 |
|
| 40 |
+
#os.system(f'echo "Removing Settings tab from UI..."')
|
| 41 |
+
#os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 42 |
|
| 43 |
# Gradio shadowRoot fix
|
| 44 |
os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."')
|
|
|
|
| 103 |
os.system(f"wget -q https://huggingface.co/darkstorm2150/Protogen_x3.4_Official_Release/resolve/main/ProtoGen_X3.4.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/ProtoGen_X3.4.safetensors")
|
| 104 |
|
| 105 |
# Critical dependency installation sequence
|
| 106 |
+
#os.system(f'echo "starting dependency cleanup..."')
|
| 107 |
+
#os.system(f'pip cache purge')
|
| 108 |
|
| 109 |
# Running multiple times to remove stubborn copies
|
| 110 |
+
#os.system(f'echo "Removing all existing numpy versions..."')
|
| 111 |
+
#os.system(f'pip uninstall -y numpy numpy numpy')
|
| 112 |
|
| 113 |
# Force NumPy 1.26.4 first
|
| 114 |
+
#os.system(f'echo "Installing NumPy 1.26.4..."')
|
| 115 |
+
#os.system(f"pip install --no-cache-dir numpy==1.26.4")
|
| 116 |
|
| 117 |
# Verify NumPy Version 1.26.4
|
| 118 |
+
#os.system(f"python -c 'import numpy; print(numpy.__version__)'")
|
| 119 |
|
| 120 |
# Install PyTorch + xformers with CUDA compatibility
|
| 121 |
+
#os.system(f'echo "Installing PyTorch..."')
|
| 122 |
+
#os.system(f"pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121 ")
|
| 123 |
+
|
| 124 |
+
#os.system(f'echo "Installing xformers..."')
|
| 125 |
+
#os.system(f"pip install --no-cache-dir xformers==0.0.25 --extra-index-url https://download.pytorch.org/whl/cu118")
|
| 126 |
+
|
| 127 |
+
# Building xformers
|
| 128 |
+
os.system(f'echo "Cloning xformers repo..."')
|
| 129 |
+
os.system(f'git clone https://github.com/facebookresearch/xformers.git /home/user/app/xformers')
|
| 130 |
|
| 131 |
+
os.system(f'echo "Installing xformers from source..."')
|
| 132 |
+
os.chdir(f'/home/user/app/xformers')
|
| 133 |
+
os.system(f'pip install --no-cache-dir -e .')
|
| 134 |
|
| 135 |
# Final verification
|
| 136 |
os.system(f'echo "Verifying NumPy, PyTorch, and xformers versions..."')
|