Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,30 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import sys
|
| 3 |
-
import shutil
|
| 4 |
import subprocess
|
|
|
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
print(f"Error installing libopenblas-base: {e}")
|
| 13 |
-
sys.exit(1)
|
| 14 |
-
|
| 15 |
-
# Step 2: Install huggingface_hub Python package using pip
|
| 16 |
-
try:
|
| 17 |
-
print("Installing huggingface_hub Python package...")
|
| 18 |
-
os.system("pip install huggingface_hub")
|
| 19 |
-
except Exception as e:
|
| 20 |
-
print(f"Error installing huggingface_hub: {e}")
|
| 21 |
-
sys.exit(1)
|
| 22 |
-
|
| 23 |
-
def clone_repo():
|
| 24 |
-
repo_url = "https://huggingface.co/svjack/sd-ggml-cpp-dp"
|
| 25 |
-
repo_dir = "sd-ggml-cpp-dp"
|
| 26 |
-
|
| 27 |
-
if not os.path.exists(repo_dir):
|
| 28 |
-
print(f"Cloning repository from {repo_url}...")
|
| 29 |
-
os.system(f"git clone {repo_url}")
|
| 30 |
else:
|
| 31 |
-
print(
|
| 32 |
-
shutil.rmtree(repo_dir)
|
| 33 |
-
os.system(f"git clone {repo_url}")
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
install_openblas_and_huggingface_hub()
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import subprocess
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
+
def run_command(command, cwd=None):
|
| 5 |
+
"""Executes a shell command and prints output"""
|
| 6 |
+
result = subprocess.run(command, cwd=cwd, text=True, capture_output=True, shell=True)
|
| 7 |
+
if result.returncode != 0:
|
| 8 |
+
print(f"Error executing command: {command}")
|
| 9 |
+
print(result.stderr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
else:
|
| 11 |
+
print(result.stdout)
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
def install_openblas():
|
| 14 |
+
# Step 1: Clone the OpenBLAS repository
|
| 15 |
+
print("Cloning the OpenBLAS repository...")
|
| 16 |
+
run_command("git clone https://github.com/OpenMathLib/OpenBLAS.git")
|
| 17 |
|
| 18 |
+
# Step 2: Change to the OpenBLAS directory
|
| 19 |
+
os.chdir("OpenBLAS")
|
|
|
|
| 20 |
|
| 21 |
+
# Step 3: Build OpenBLAS
|
| 22 |
+
print("Building OpenBLAS...")
|
| 23 |
+
run_command("make")
|
| 24 |
|
| 25 |
+
# Step 4: Install OpenBLAS
|
| 26 |
+
print("Installing OpenBLAS...")
|
| 27 |
+
run_command("sudo make install")
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
+
install_openblas()
|