ford442 commited on
Commit
f4ae231
·
verified ·
1 Parent(s): 97a7cb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -4,20 +4,21 @@
4
  # in the Software without restriction, including without limitation the rights
5
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6
  # copies of the Software, and to permit persons to whom the Software is
7
- #import spaces
8
- #import subprocess
9
  import os
10
- #subprocess.run(['sh', './torch.sh'])
11
 
12
- os.putenv('PYTORCH_NVML_BASED_CUDA_CHECK','1')
13
- os.putenv('TORCH_LINALG_PREFER_CUSOLVER','1')
14
- alloc_conf_parts = [
15
- 'expandable_segments:True',
16
- 'pinned_use_background_threads:True' # Specific to pinned memory.
17
- ]
18
- os.environ['PYTORCH_CUDA_ALLOC_CONF'] = ','.join(alloc_conf_parts)
 
 
19
  os.environ["SAFETENSORS_FAST_GPU"] = "1"
20
- os.putenv('HF_HUB_ENABLE_HF_TRANSFER','1')
21
 
22
  import gradio as gr
23
  import numpy as np
 
4
  # in the Software without restriction, including without limitation the rights
5
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6
  # copies of the Software, and to permit persons to whom the Software is
7
+ import spaces
8
+ import subprocess
9
  import os
 
10
 
11
+ @spaces.GPU(required=True)
12
+ def install_flashattn():
13
+ subprocess.run(['sh', './flashattn.sh'])
14
+
15
+ install_flashattn()
16
+
17
+ os.environ['PYTORCH_NVML_BASED_CUDA_CHECK'] = '1'
18
+ os.environ['TORCH_LINALG_PREFER_CUSOLVER'] = '1'
19
+ os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True,pinned_use_background_threads:True'
20
  os.environ["SAFETENSORS_FAST_GPU"] = "1"
21
+ os.environ['HF_HUB_ENABLE_HF_TRANSFER'] = '1'
22
 
23
  import gradio as gr
24
  import numpy as np