kadirnar commited on
Commit
5204f9b
·
verified ·
1 Parent(s): 0bb4b93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -21
app.py CHANGED
@@ -12,32 +12,22 @@ import os
12
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
13
 
14
 
15
- def install_apex():
16
- # Apex repository'sini klonla
17
- subprocess.run(["git", "clone", "https://github.com/NVIDIA/apex"], check=True)
18
- # Apex dizinine git
19
- subprocess.run(["cd", "apex"], check=True)
20
- # Apex'i kur
21
- try:
22
- subprocess.run([
23
- "pip", "install", "-v", "--disable-pip-version-check", "--no-cache-dir",
24
- "--no-build-isolation", "--config-settings", "--build-option=--cpp_ext",
25
- "--config-settings", "--build-option=--cuda_ext", "./apex"
26
- ], check=True)
27
- except subprocess.CalledProcessError:
28
- # Eğer yukarıdaki komut başarısız olursa, alternatif kurulum komutunu dene
29
- subprocess.run([
30
- "pip", "install", "-v", "--disable-pip-version-check", "--no-cache-dir",
31
- "--no-build-isolation", "--global-option=--cpp_ext", "--global-option=--cuda_ext",
32
- "./apex"
33
- ], check=True)
34
 
35
  try:
36
  import apex
37
  except ModuleNotFoundError:
38
- print("Apex not found, installing...")
39
- install_apex()
 
 
40
 
 
41
  def download_t5_model(model_id, save_directory):
42
  # Modelin tokenizer'ını ve modeli indir
43
  model = T5ForConditionalGeneration.from_pretrained(model_id)
 
12
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
13
 
14
 
15
+ def install_apex_without_cuda():
16
+ cmd = [
17
+ 'pip', 'install', '-v', '--disable-pip-version-check', '--no-cache-dir',
18
+ 'git+https://github.com/NVIDIA/apex.git'
19
+ ]
20
+ subprocess.run(cmd, check=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  try:
23
  import apex
24
  except ModuleNotFoundError:
25
+ print("Apex not found, installing without CUDA extensions...")
26
+ install_apex_without_cuda()
27
+ # After installation, try to import apex again
28
+ import apex
29
 
30
+
31
  def download_t5_model(model_id, save_directory):
32
  # Modelin tokenizer'ını ve modeli indir
33
  model = T5ForConditionalGeneration.from_pretrained(model_id)