From 311404e2585a6e32cc0732c058120e90fe506aca Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:11:05 -0300 Subject: [PATCH] Reuse disk-cache-dir parameter for flexgen --- server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index daf300e..d38e668 100644 --- a/server.py +++ b/server.py @@ -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)