FlawedLLM commited on
Commit
dde0367
·
verified ·
1 Parent(s): fd1b3b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -39
app.py CHANGED
@@ -1,47 +1,47 @@
1
- import torch; torch.version.cuda
2
- # from huggingface_hub import login, HfFolder
3
- import subprocess
4
- # import getpass
 
 
 
 
 
 
 
 
5
 
6
- # def run_sudo_command(cmd):
 
 
 
 
7
  # try:
8
- # password = getpass.getpass(prompt="Enter your sudo password: ") # Securely get the password
9
- # result = subprocess.run(["sudo", "-S"] + cmd, input=password.encode(), capture_output=True, text=True, check=True)
10
  # print(result.stdout)
11
  # except subprocess.CalledProcessError as e:
12
  # print(f"Error executing command: {e.stderr}")
13
-
14
- # # Run the ldconfig command
15
- # run_sudo_command(["ldconfig", "/usr/lib64-nvidia"])
16
-
17
- def run_command(cmd, shell=False):
18
- """Runs a shell command and prints the output."""
19
- try:
20
- result = subprocess.run(cmd, shell=shell, capture_output=True, text=True, check=True)
21
- print(result.stdout)
22
- except subprocess.CalledProcessError as e:
23
- print(f"Error executing command: {e.stderr}")
24
- subprocess.run(["pip", "install", "--upgrade", "pip"], check=True)
25
- # subprocess.run(["pip", "install", "--upgrade", "torch"], check=True)
26
- # subprocess.run(["pip", "install", "--upgrade", "transformers"], check=True)
27
- # Pip install command as a list
28
- pip_command = [
29
- "pip",
30
- "install",
31
- "--upgrade",
32
- "--force-reinstall",
33
- "--no-cache-dir",
34
- "torch==2.1.1",
35
- "triton",
36
- "--index-url",
37
- "https://download.pytorch.org/whl/cu121"
38
- ]
39
- run_command(pip_command)
40
- run_command(["pip", "install", "--no-deps", "trl", "peft", "accelerate", "bitsandbytes"])
41
- # subprocess.run(["pip", "install", "--upgrade", "peft"], check=True)
42
- subprocess.run(["pip", "install", "xformers"], check=True)
43
- # subprocess.run(["pip", "install", "--upgrade", "accelerate"], check=True)
44
- subprocess.run(["unsloth[cu121-ampere-torch211] @ git+https://github.com/unslothai/unsloth.git"], check=True)
45
  # import subprocess
46
 
47
 
@@ -60,6 +60,31 @@ subprocess.run(["unsloth[cu121-ampere-torch211] @ git+https://github.com/unsloth
60
 
61
  # # 5. Install additional pip packages without dependencies
62
  # run_command("pip install --no-deps trl peft accelerate bitsandbytes")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  import os
65
  HF_TOKEN = os.environ["HF_TOKEN"]
 
1
+ # import torch; torch.version.cuda
2
+ # # from huggingface_hub import login, HfFolder
3
+ # import subprocess
4
+ # # import getpass
5
+
6
+ # # def run_sudo_command(cmd):
7
+ # # try:
8
+ # # password = getpass.getpass(prompt="Enter your sudo password: ") # Securely get the password
9
+ # # result = subprocess.run(["sudo", "-S"] + cmd, input=password.encode(), capture_output=True, text=True, check=True)
10
+ # # print(result.stdout)
11
+ # # except subprocess.CalledProcessError as e:
12
+ # # print(f"Error executing command: {e.stderr}")
13
 
14
+ # # # Run the ldconfig command
15
+ # # run_sudo_command(["ldconfig", "/usr/lib64-nvidia"])
16
+
17
+ # def run_command(cmd, shell=False):
18
+ # """Runs a shell command and prints the output."""
19
  # try:
20
+ # result = subprocess.run(cmd, shell=shell, capture_output=True, text=True, check=True)
 
21
  # print(result.stdout)
22
  # except subprocess.CalledProcessError as e:
23
  # print(f"Error executing command: {e.stderr}")
24
+ # subprocess.run(["pip", "install", "--upgrade", "pip"], check=True)
25
+ # # subprocess.run(["pip", "install", "--upgrade", "torch"], check=True)
26
+ # # subprocess.run(["pip", "install", "--upgrade", "transformers"], check=True)
27
+ # # Pip install command as a list
28
+ # pip_command = [
29
+ # "pip",
30
+ # "install",
31
+ # "--upgrade",
32
+ # "--force-reinstall",
33
+ # "--no-cache-dir",
34
+ # "torch==2.1.1",
35
+ # "triton",
36
+ # "--index-url",
37
+ # "https://download.pytorch.org/whl/cu121"
38
+ # ]
39
+ # run_command(pip_command)
40
+ # run_command(["pip", "install", "--no-deps", "trl", "peft", "accelerate", "bitsandbytes"])
41
+ # # subprocess.run(["pip", "install", "--upgrade", "peft"], check=True)
42
+ # subprocess.run(["pip", "install", "xformers"], check=True)
43
+ # # subprocess.run(["pip", "install", "--upgrade", "accelerate"], check=True)
44
+ # subprocess.run(["unsloth[cu121-ampere-torch211] @ git+https://github.com/unslothai/unsloth.git"], check=True)
 
 
 
 
 
 
 
 
 
 
 
45
  # import subprocess
46
 
47
 
 
60
 
61
  # # 5. Install additional pip packages without dependencies
62
  # run_command("pip install --no-deps trl peft accelerate bitsandbytes")
63
+ import subprocess
64
+
65
+ def run_command(cmd):
66
+ try:
67
+ result = subprocess.run(cmd, capture_output=True, text=True, check=True)
68
+ print(result.stdout)
69
+ except subprocess.CalledProcessError as e:
70
+ print(f"Error executing command: {e.stderr}")
71
+
72
+ # Pip install xformers
73
+ run_command([
74
+ "pip",
75
+ "install",
76
+ "-U",
77
+ "xformers<0.0.26",
78
+ "--index-url",
79
+ "https://download.pytorch.org/whl/cu121"
80
+ ])
81
+
82
+ # Pip install unsloth from GitHub
83
+ run_command([
84
+ "pip",
85
+ "install",
86
+ "unsloth[kaggle-new] @ git+https://github.com/unslothai/unsloth.git"
87
+ ])
88
 
89
  import os
90
  HF_TOKEN = os.environ["HF_TOKEN"]