yukee1992 commited on
Commit
bd190c7
·
verified ·
1 Parent(s): 88d7cb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -28,10 +28,13 @@ import accelerate # Add this for better memory management
28
  # =============================================
29
  # MEMORY OPTIMIZATION SETTINGS
30
  # =============================================
31
- # Enable memory efficient attention if available
32
- if hasattr(torch, 'backends') and hasattr(torch.backends, 'cuda') and torch.backends.cuda.is_enabled():
 
33
  torch.backends.cuda.enable_flash_sdp(True)
34
  torch.backends.cuda.enable_mem_efficient_sdp(True)
 
 
35
 
36
  # Set environment variables for memory optimization
37
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"
 
28
  # =============================================
29
  # MEMORY OPTIMIZATION SETTINGS
30
  # =============================================
31
+ # Check if CUDA is available and set memory optimization
32
+ if torch.cuda.is_available():
33
+ print("✅ CUDA available, enabling GPU optimizations")
34
  torch.backends.cuda.enable_flash_sdp(True)
35
  torch.backends.cuda.enable_mem_efficient_sdp(True)
36
+ else:
37
+ print("⚠️ CUDA not available, running on CPU")
38
 
39
  # Set environment variables for memory optimization
40
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"