blog icon indicating copy to clipboard operation
blog copied to clipboard

Division by Zero error upon implementing the diffuser pipeline in the network

Open Vaibhav-Fulara opened this issue 2 years ago • 0 comments

Hello! While trying to run the model on my own dataset, I tried to run the source code on Google Colab as well as my local machine and in both the places, I got the following error as an outcome to my code run. I can sees it is a division by zero error but cannot understand the cause. Please help: in <cell line: 3>:3 │ │ │ │ /usr/local/lib/python3.10/dist-packages/diffusers/pipelines/pipeline_utils.py:1039 in │ │ from_pretrained │ │ │ │ 1036 │ │ │ │ loaded_sub_model = passed_class_obj[name] │ │ 1037 │ │ │ else: │ │ 1038 │ │ │ │ # load sub model │ │ ❱ 1039 │ │ │ │ loaded_sub_model = load_sub_model( │ │ 1040 │ │ │ │ │ library_name=library_name, │ │ 1041 │ │ │ │ │ class_name=class_name, │ │ 1042 │ │ │ │ │ importable_classes=importable_classes, │ │ │ │ /usr/local/lib/python3.10/dist-packages/diffusers/pipelines/pipeline_utils.py:445 in │ │ load_sub_model │ │ │ │ 442 │ │ │ 443 │ # check if the module is in a subdirectory │ │ 444 │ if os.path.isdir(os.path.join(cached_folder, name)): │ │ ❱ 445 │ │ loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwar │ │ 446 │ else: │ │ 447 │ │ # else load from the root directory │ │ 448 │ │ loaded_sub_model = load_method(cached_folder, **loading_kwargs) │ │ │ │ /usr/local/lib/python3.10/dist-packages/diffusers/models/modeling_utils.py:610 in │ │ from_pretrained │ │ │ │ 607 │ │ │ │ else: # else let accelerate handle loading and dispatching. │ │ 608 │ │ │ │ │ # Load weights and dispatch according to the device_map │ │ 609 │ │ │ │ │ # by default the device_map is None and the weights are loaded on th │ │ ❱ 610 │ │ │ │ │ accelerate.load_checkpoint_and_dispatch(model, model_file, device_ma │ │ 611 │ │ │ │ │ │ 612 │ │ │ │ loading_info = { │ │ 613 │ │ │ │ │ "missing_keys": [], │ │ │ │ /usr/local/lib/python3.10/dist-packages/accelerate/big_modeling.py:466 in │ │ load_checkpoint_and_dispatch │ │ │ │ 463 │ │ │ "'sequential'." │ │ 464 │ │ ) │ │ 465 │ if device_map != "sequential": │ │ ❱ 466 │ │ max_memory = get_balanced_memory( │ │ 467 │ │ │ model, │ │ 468 │ │ │ max_memory=max_memory, │ │ 469 │ │ │ no_split_module_classes=no_split_module_classes, │

/usr/local/lib/python3.10/dist-packages/accelerate/utils/modeling.py:526 in get_balanced_memory
523 │ module_sizes = {n: v for n, v in module_sizes.items() if n not in leaves}
524 │ # Once removed, leaves are the final modules.
525 │ leaves = [n for n in module_sizes if len([p for p in module_sizes if n == "" or p.st
❱ 526 │ mean_leaves = int(sum([module_sizes[n] for n in leaves]) / len(leaves))
527 │ buffer = int(1.25 * max(buffer, mean_leaves))
528 │ per_gpu += buffer

ZeroDivisionError: division by zero                                                                   

Vaibhav-Fulara avatar May 18 '23 12:05 Vaibhav-Fulara