Commit 7e1e193f authored by comfyanonymous's avatar comfyanonymous
Browse files

Automatically enable lowvram mode if vram is less than 4GB.

Use: --normalvram to disable it.
parent e9d3ac2b
...@@ -13,17 +13,23 @@ total_vram_available_mb = -1 ...@@ -13,17 +13,23 @@ total_vram_available_mb = -1
import sys import sys
set_vram_to = NORMAL_VRAM set_vram_to = NORMAL_VRAM
if "--lowvram" in sys.argv:
set_vram_to = LOW_VRAM
if "--novram" in sys.argv:
set_vram_to = NO_VRAM
try: try:
import torch import torch
total_vram = torch.cuda.mem_get_info(torch.cuda.current_device())[1] / (1024 * 1024) total_vram = torch.cuda.mem_get_info(torch.cuda.current_device())[1] / (1024 * 1024)
if total_vram <= 4096 and not "--normalvram" in sys.argv:
print("Trying to enable lowvram mode because your GPU seems to have 4GB or less. If you don't want this use: --normalvram")
set_vram_to = LOW_VRAM
except: except:
pass pass
if "--lowvram" in sys.argv:
set_vram_to = LOW_VRAM
if "--novram" in sys.argv:
set_vram_to = NO_VRAM
if set_vram_to != NORMAL_VRAM: if set_vram_to != NORMAL_VRAM:
try: try:
import accelerate import accelerate
......
...@@ -14,6 +14,7 @@ if __name__ == "__main__": ...@@ -14,6 +14,7 @@ if __name__ == "__main__":
print("\t--dont-upcast-attention\t\tDisable upcasting of attention \n\t\t\t\t\tcan boost speed but increase the chances of black images.\n") print("\t--dont-upcast-attention\t\tDisable upcasting of attention \n\t\t\t\t\tcan boost speed but increase the chances of black images.\n")
print("\t--use-split-cross-attention\tUse the split cross attention optimization instead of the sub-quadratic one.\n\t\t\t\t\tIgnored when xformers is used.") print("\t--use-split-cross-attention\tUse the split cross attention optimization instead of the sub-quadratic one.\n\t\t\t\t\tIgnored when xformers is used.")
print() print()
print("\t--normalvram\t\t\tUsed to force normal vram use if lowvram gets automatically enabled.")
print("\t--lowvram\t\t\tSplit the unet in parts to use less vram.") print("\t--lowvram\t\t\tSplit the unet in parts to use less vram.")
print("\t--novram\t\t\tWhen lowvram isn't enough.") print("\t--novram\t\t\tWhen lowvram isn't enough.")
print() print()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment