FlawedLLM commited on
Commit
a6f0495
·
verified ·
1 Parent(s): c7449db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -9
app.py CHANGED
@@ -1,15 +1,39 @@
1
 
2
- # from huggingface_hub import login, HfFolder
 
 
 
 
 
 
 
 
 
 
3
  import subprocess
4
 
5
- subprocess.run(["pip", "install", "--upgrade", "pip"], check=True)
6
- subprocess.run(["pip", "install", "--upgrade", "torch"], check=True)
7
- subprocess.run(["pip", "install", "--upgrade", "transformers"], check=True)
8
- subprocess.run(["pip", "install", "--upgrade", "bitsandbytes"], check=True)
9
- subprocess.run(["pip", "install", "--upgrade", "peft"], check=True)
10
- subprocess.run(["pip", "install", "--upgrade", "xformers"], check=True)
11
- subprocess.run(["pip", "install", "--upgrade", "accelerate"], check=True)
12
- subprocess.run(["pip", "install", "unsloth[cu121-ampere-torch230] @ git+https://github.com/unslothai/unsloth.git"], check=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  import os
15
  HF_TOKEN = os.environ["HF_TOKEN"]
 
1
 
2
+ # # from huggingface_hub import login, HfFolder
3
+ # import subprocess
4
+
5
+ # subprocess.run(["pip", "install", "--upgrade", "pip"], check=True)
6
+ # subprocess.run(["pip", "install", "--upgrade", "torch"], check=True)
7
+ # subprocess.run(["pip", "install", "--upgrade", "transformers"], check=True)
8
+ # subprocess.run(["pip", "install", "--upgrade", "bitsandbytes"], check=True)
9
+ # subprocess.run(["pip", "install", "--upgrade", "peft"], check=True)
10
+ # subprocess.run(["pip", "install", "--upgrade", "xformers"], check=True)
11
+ # subprocess.run(["pip", "install", "--upgrade", "accelerate"], check=True)
12
+ # subprocess.run(["pip", "install", "unsloth[cu121-ampere-torch230] @ git+https://github.com/unslothai/unsloth.git"], check=True)
13
  import subprocess
14
 
15
+ def run_command(cmd, shell=False):
16
+ """Runs a shell command and prints the output."""
17
+ try:
18
+ result = subprocess.run(cmd, shell=shell, capture_output=True, text=True, check=True)
19
+ print(result.stdout)
20
+ except subprocess.CalledProcessError as e:
21
+ print(f"Error executing command: {e.stderr}")
22
+
23
+ # 1. Create the conda environment
24
+ run_command("conda create -y --name unsloth_env python=3.10")
25
+
26
+ # 2. Activate the environment (Note: Requires shell=True)
27
+ run_command("conda activate unsloth_env", shell=True)
28
+
29
+ # 3. Install PyTorch and related packages with conda
30
+ run_command("conda install pytorch-cuda=<12.1/11.8> pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformers")
31
+
32
+ # 4. Install unsloth from the GitHub repository with pip
33
+ run_command("pip install \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git\"")
34
+
35
+ # 5. Install additional pip packages without dependencies
36
+ run_command("pip install --no-deps trl peft accelerate bitsandbytes")
37
 
38
  import os
39
  HF_TOKEN = os.environ["HF_TOKEN"]