mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-12-23 21:18:00 +01:00
Reuse disk-cache-dir parameter for flexgen
This commit is contained in:
parent
f3c75bbd64
commit
311404e258
@ -42,7 +42,7 @@ parser.add_argument('--load-in-8bit', action='store_true', help='Load the model
|
||||
parser.add_argument('--bf16', action='store_true', help='Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU.')
|
||||
parser.add_argument('--auto-devices', action='store_true', help='Automatically split the model across the available GPU(s) and CPU.')
|
||||
parser.add_argument('--disk', action='store_true', help='If the model is too large for your GPU(s) and CPU combined, send the remaining layers to the disk.')
|
||||
parser.add_argument('--disk-cache-dir', type=str, help='Directory to save the disk cache to. Defaults to "cache/".')
|
||||
parser.add_argument('--disk-cache-dir', type=str, default="cache", help='Directory to save the disk cache to. Defaults to "cache".')
|
||||
parser.add_argument('--gpu-memory', type=int, help='Maximum GPU memory in GiB to allocate. This is useful if you get out of memory errors while trying to generate text. Must be an integer number.')
|
||||
parser.add_argument('--cpu-memory', type=int, help='Maximum CPU memory in GiB to allocate for offloaded weights. Must be an integer number. Defaults to 99.')
|
||||
parser.add_argument('--flexgen', action='store_true', help='Enable the use of FlexGen offloading.')
|
||||
@ -122,7 +122,7 @@ def load_model(model_name):
|
||||
elif args.flexgen:
|
||||
gpu = TorchDevice("cuda:0")
|
||||
cpu = TorchDevice("cpu")
|
||||
disk = TorchDisk("cache")
|
||||
disk = TorchDisk(args.disk_cache_dir)
|
||||
env = Env(gpu=gpu, cpu=cpu, disk=disk, mixed=TorchMixedDevice([gpu, cpu, disk]))
|
||||
|
||||
# Offloading policy
|
||||
@ -178,7 +178,7 @@ def load_model(model_name):
|
||||
print(f"\033[1;32;1mAuto-assiging --gpu-memory {suggestion} for your GPU to try to prevent out-of-memory errors.\nYou can manually set other values.\033[0;37;0m")
|
||||
params.append(f"max_memory={{0: '{suggestion}GiB', 'cpu': '{args.cpu_memory or '99'}GiB'}}")
|
||||
if args.disk:
|
||||
params.append(f"offload_folder='{args.disk_cache_dir or 'cache'}'")
|
||||
params.append(f"offload_folder='{args.disk_cache_dir}'")
|
||||
|
||||
command = f"{command}(Path(f'models/{model_name}'), {', '.join(set(params))})"
|
||||
model = eval(command)
|
||||
|
Loading…
Reference in New Issue
Block a user