o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
INFO move text encoders to gpu…
- User
INFO move text encoders to gpu ]8;id=660757;file:///kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py\flux_train_network.py]8;;:]8;id=351556;file:///kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py#216\216]8;;
[rank1]: Traceback (most recent call last): [rank1]: File "/kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py", line 519, in [rank1]: trainer.train(args) [rank1]: File "/kaggle/temp/kohya_ss/sd-scripts/train_network.py", line 402, in train [rank1]: self.cache_text_encoder_outputs_if_needed(args, accelerator, unet, vae, text_encoders, train_dataset_group, weight_dtype) [rank1]: File "/kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py", line 218, in cache_text_encoder_outputs_if_needed [rank1]: text_encoders[1].to(accelerator.device) [rank1]: File "/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2883, in to [rank1]: return super().to(*args, **kwargs) [rank1]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1174, in to [rank1]: return self._apply(convert) [rank1]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 780, in _apply [rank1]: module._apply(fn) [rank1]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 805, in _apply [rank1]: param_applied = fn(param) [rank1]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1167, in convert [rank1]: raise NotImplementedError( [rank1]: NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device. [rank0]: Traceback (most recent call last): [rank0]: File "/kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py", line 519, in [rank0]: trainer.train(args) [rank0]: File "/kaggle/temp/kohya_ss/sd-scripts/train_network.py", line 402, in train [rank0]: self.cache_text_encoder_outputs_if_needed(args, accelerator, unet, vae, text_encoders, train_dataset_group, weight_dtype) [rank0]: File "/kaggle/temp/kohya_ss/sd-scripts/./flux_train_network.py", line 218, in cache_text_encoder_outputs_if_needed [rank0]: text_encoders[1].to(accelerator.device) [rank0]: File "/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2883, in to [rank0]: return super().to(*args, **kwargs) [rank0]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1174, in to [rank0]: return self._apply(convert) [rank0]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 780, in _apply [rank0]: module._apply(fn) [rank0]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 805, in _apply [rank0]: param_applied = fn(param) [rank0]: File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1167, in convert [rank0]: raise NotImplementedError( [rank0]: NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device. [rank0]:[W921 21:39:53.674576622 ProcessGroupNCCL.cpp:1168] Warning: WARNING: process group has NOT been destroyed before we destruct ProcessGroupNCCL. On normal program exit, the application should call destroy_process_group to ensure that any pending NCCL operations have finished in this process. In rare cases this process can exit before this point and block the progress of another member of the process group. This constraint has always been present, but this warning has only been added since PyTorch 2.4 (function operator()) W0921 21:39:55.660000 135639820904256 torch/distributed/elastic/multiprocessing/api.py:858] Sending process 193 closing signal SIGTERM E0921 21:39:55.724000 135639820904256 torch/distributed/elastic/multiprocessing/api.py:833] failed (exitcode: 1) local_rank: 1 (pid: 194) of binary: /opt/conda/bin/python3.10 Traceback (most recent call last): File "/opt/conda/bin/accelerate", line 8, in sys.exit(main()) File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main args.func(args) File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/launch.py", line 1097, in launch_command multi_gpu_launcher(args) File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/launch.py", line 734, in multi_gpu_launcher distrib_run.run(args) File "/opt/conda/lib/python3.10/site-packages/torch/distributed/run.py", line 892, in run elastic_launch( File "/opt/conda/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 133, in return launch_agent(self._config, self._entrypoint, list(args)) File "/opt/conda/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 264, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError: - Assistant
从您提供的错误信息来看,程序在执行
text_encoders[1].to(accelerator.device)时发生了NotImplementedError异常。具体错误信息是:NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.这意味着程序尝试将一个包含元张量(
meta tensor)的模型从'meta'设备复制到其他设备(例如 GPU),但由于元张量没有实际数据,这种操作是不被允许的。元张量是一种特殊的张量类型,通常用于占位符或延迟初始化。在将模型移动到实际设备之前,必须确保模型的参数已经被正确初始化,而不是元张量。
可能的解决方法:
-
确保模型正确初始化: 在将模型移动到设备之前,确认模型的参数已经被正确加载和初始化,而不再是元张量。
-
检查模型加载方式: 如果您使用了
from_pretrained()方法加载模型,请确保没有设置device_map='auto'或low_cpu_mem_usage=True。这些参数可能会导致模型被加载为元张量。尝试移除这些参数或将其设置为默认值。 -
使用
to_empty()方法: 如果确实需要在包含元张量的情况下移动模型,可以按照错误提示使用torch.nn.Module.to_empty()方法来替代to()方法。 -
更新相关库版本: 确保您使用的 PyTorch 和 Transformers 库是最新版本。某些版本中可能存在与元张量处理相关的已知问题,更新版本可能已解决这些问题。
建议您:
-