sandeshrajx commited on
Commit
6ffc1bc
1 Parent(s): d42bc00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -9,20 +9,25 @@ import spaces
9
  from transformers import T5ForConditionalGeneration, T5Tokenizer
10
  import os
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
13
- install_options = [
14
- "--disable-pip-version-check",
15
- "--no-cache-dir",
16
- "--no-build-isolation",
17
- "--config-settings", "--build-option=--cpp_ext",
18
- "--config-settings", "--build-option=--cuda_ext"
19
- ]
20
- print("tseting")
21
- subprocess.run(
22
- ["pip", "install", "-v"] + install_options + ["git+https://github.com/sandeshrajbhandari/apex.git#egg=apex"],
23
- check=True,
24
- capture_output=True
25
- )
26
  def download_t5_model(model_id, save_directory):
27
  # Modelin tokenizer'ını ve modeli indir
28
  model = T5ForConditionalGeneration.from_pretrained(model_id)
 
9
  from transformers import T5ForConditionalGeneration, T5Tokenizer
10
  import os
11
 
12
+ def install_apex():
13
+ # Install Apex in editable mode from the specified GitHub repository
14
+ cmd = [
15
+ 'pip', 'install', '-v','--no-cache-dir', '--no-build-isolation',
16
+ '--config-settings', 'build-option=--cpp_ext', '--config-settings',
17
+ 'build-option=--cuda_ext', 'git+https://github.com/sandeshrajbhandari/apex.git#egg=apex'
18
+ ]
19
+ subprocess.run(cmd, check=True, capture_output=True)
20
+
21
+ try:
22
+ import apex
23
+ except ModuleNotFoundError:
24
+ print("Apex not found, installing...")
25
+ install_apex()
26
+ # Try to import Apex again after installation
27
+ import apex
28
+
29
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
30
+
 
 
 
 
 
 
 
 
 
 
 
 
31
  def download_t5_model(model_id, save_directory):
32
  # Modelin tokenizer'ını ve modeli indir
33
  model = T5ForConditionalGeneration.from_pretrained(model_id)