Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,13 +12,35 @@ import os
|
|
12 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
13 |
|
14 |
def install_apex():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
cmd = [
|
16 |
'pip', 'install', '-v', '--disable-pip-version-check', '--no-cache-dir',
|
17 |
'--no-build-isolation', '--config-settings', '--build-option=--cpp_ext',
|
18 |
-
'--config-settings', '--build-option=--cuda_ext', '
|
19 |
]
|
20 |
subprocess.run(cmd, check=True)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def download_t5_model(model_id, save_directory):
|
23 |
# Modelin tokenizer'ını ve modeli indir
|
24 |
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 |
def install_apex():
|
15 |
+
# Apex reposunu klonla (eğer zaten klonlanmamışsa)
|
16 |
+
if not os.path.exists('apex'):
|
17 |
+
subprocess.run(['git', 'clone', 'https://github.com/NVIDIA/apex'], check=True)
|
18 |
+
|
19 |
+
# Apex dizinine git
|
20 |
+
os.chdir('apex')
|
21 |
+
|
22 |
+
# Apex'i kur
|
23 |
cmd = [
|
24 |
'pip', 'install', '-v', '--disable-pip-version-check', '--no-cache-dir',
|
25 |
'--no-build-isolation', '--config-settings', '--build-option=--cpp_ext',
|
26 |
+
'--config-settings', '--build-option=--cuda_ext', '.'
|
27 |
]
|
28 |
subprocess.run(cmd, check=True)
|
29 |
|
30 |
+
# Orjinal dizinine geri dön
|
31 |
+
os.chdir('..')
|
32 |
+
|
33 |
+
try:
|
34 |
+
import apex
|
35 |
+
except ModuleNotFoundError:
|
36 |
+
print("Apex not found, installing...")
|
37 |
+
install_apex()
|
38 |
+
# Kurulumdan sonra apex'i import etmeyi dene
|
39 |
+
import apex
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
def download_t5_model(model_id, save_directory):
|
45 |
# Modelin tokenizer'ını ve modeli indir
|
46 |
model = T5ForConditionalGeneration.from_pretrained(model_id)
|