hsuwill000 commited on
Commit
7a13824
·
verified ·
1 Parent(s): 5177727

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -38
app.py CHANGED
@@ -1,47 +1,30 @@
1
- import os
2
- import sys
3
- import shutil
4
  import subprocess
 
5
 
6
- def install_openblas_and_huggingface_hub():
7
- # Step 1: Install OpenBLAS base using apt-get
8
- try:
9
- print("Installing libopenblas-base...")
10
- os.system("sudo apt-get update && sudo apt-get install -y libopenblas-base")
11
- except Exception as e:
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(f"Removing existing repository {repo_dir} and cloning again...")
32
- shutil.rmtree(repo_dir)
33
- os.system(f"git clone {repo_url}")
34
 
35
- assert os.path.exists(repo_dir), "Failed to clone repository!"
 
 
 
36
 
37
- def main():
38
- # Install necessary packages
39
- install_openblas_and_huggingface_hub()
40
 
41
- # Clone repository
42
- clone_repo()
 
43
 
44
- print("Setup complete!")
 
 
45
 
46
  if __name__ == "__main__":
47
- main()
 
 
 
 
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()