John6666 commited on
Commit
1cb4ac2
·
verified ·
1 Parent(s): 5776bac

Upload mod.py

Browse files
Files changed (1) hide show
  1. mod.py +10 -1
mod.py CHANGED
@@ -13,7 +13,16 @@ from env import num_cns, model_trigger, HF_TOKEN, CIVITAI_API_KEY, DOWNLOAD_LORA
13
  from modutils import download_things
14
 
15
 
16
- subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
 
 
 
 
 
 
 
 
 
17
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
18
  #subprocess.run('pip cache purge', shell=True)
19
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
13
  from modutils import download_things
14
 
15
 
16
+ IS_ZERO = True if os.getenv("SPACES_ZERO_GPU", None) else False
17
+ if torch.cuda.is_available():
18
+ torch.backends.cudnn.deterministic = True
19
+ torch.backends.cudnn.benchmark = False
20
+ torch.backends.cuda.matmul.allow_tf32 = True
21
+ if IS_ZERO:
22
+ subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
23
+ torch.set_float32_matmul_precision("high") # https://pytorch.org/blog/accelerating-generative-ai-3/
24
+
25
+
26
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
27
  #subprocess.run('pip cache purge', shell=True)
28
  device = "cuda" if torch.cuda.is_available() else "cpu"