Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.59k stars 510 forks source link

DataParallel Multi-gpu training problem #2004

Open JaehwanOh-R opened 5 months ago

JaehwanOh-R commented 5 months ago

🐛 Describe the bug

[2024-05-27 08:06:37] INFO - sg_trainer.py - Started training for 300 epochs (0/299)

Train epoch 0:   0%|          | 0/4690 [00:02<?, ?it/s]
[2024-05-27 08:06:39] INFO - base_sg_logger.py - [CLEANUP] - Successfully stopped system monitoring process
[2024-05-27 08:06:39] ERROR - sg_trainer_utils.py - Uncaught exception
Traceback (most recent call last):
  File "train.py", line 139, in <module>
    trainer.train(model=net, training_params=train_params, train_loader=train_loader, valid_loader=valid_loader)
  File "/workspace/kais-env/lib/python3.8/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 1530, in train
    train_metrics_tuple = self._train_epoch(context=context, silent_mode=silent_mode)
  File "/workspace/kais-env/lib/python3.8/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 504, in _train_epoch
    outputs = self.net(inputs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 172, in forward
    return self.gather(outputs, self.output_device)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 184, in gather
    return gather(outputs, output_device, dim=self.dim)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 86, in gather
    res = gather_map(outputs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  [Previous line repeated 1 more time]
TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "train.py", line 139, in <module>
    trainer.train(model=net, training_params=train_params, train_loader=train_loader, valid_loader=valid_loader)
  File "/workspace/kais-env/lib/python3.8/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 1530, in train
    train_metrics_tuple = self._train_epoch(context=context, silent_mode=silent_mode)
  File "/workspace/kais-env/lib/python3.8/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 504, in _train_epoch
    outputs = self.net(inputs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 172, in forward
    return self.gather(outputs, self.output_device)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 184, in gather
    return gather(outputs, output_device, dim=self.dim)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 86, in gather
    res = gather_map(outputs)
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  File "/workspace/kais-env/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py", line 81, in gather_map
    return type(out)(map(gather_map, zip(*outputs)))
  [Previous line repeated 1 more time]
TypeError: 'int' object is not iterable

An error occurred in pytorch's father_map function, and when I output the output of the model, an error occurred because a non-tensor value was being output during the model output. Why is a non-tensor value output among the output of the model?

Versions

PyTorch version: 1.13.1+cu117 Is debug build: False CUDA used to build PyTorch: 11.7 ROCM used to build PyTorch: N/A

OS: CentOS Linux 7 (Core) (x86_64) GCC version: Could not collect Clang version: Could not collect CMake version: Could not collect Libc version: glibc-2.17

Python version: 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 16:01:55) [GCC 11.3.0] (64-bit runtime) Python platform: Linux-5.4.0-172-generic-x86_64-with-glibc2.10 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090 GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version: 555.42.02 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 167 Model name: 11th Gen Intel(R) Core(TM) i9-11900KF @ 3.50GHz Stepping: 1 CPU MHz: 4958.324 CPU max MHz: 5300.0000 CPU min MHz: 800.0000 BogoMIPS: 7008.00 Virtualization: VT-x L1d cache: 48K L1i cache: 32K L2 cache: 512K L3 cache: 16384K NUMA node0 CPU(s): 0-15 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap avx512ifma clflushopt intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid md_clear flush_l1d arch_capabilities

Versions of relevant libraries: [pip3] mypy-extensions==0.4.3 [pip3] numpy==1.22.4 [pip3] onnx==1.15.0 [pip3] onnxruntime==1.15.0 [pip3] onnxsim==0.4.36 [pip3] pytorch-lightning==1.8.0 [pip3] pytorch-tabnet==4.0 [pip3] torch==1.13.1 [pip3] torchaudio==0.11.0 [pip3] torchcam==0.3.2 [pip3] torchmetrics==0.8.0 [pip3] torchsummary==1.5.1 [pip3] torchvision==0.14.1 [conda] Could not collect

BloodAxe commented 5 months ago

It would be great to get some more details of the issue:

JaehwanOh-R commented 5 months ago

It would be great to get some more details of the issue:

  • What model are you training
  • How are you launching training (torchrun, train_from_recipe, maybe your custom train.py)
  • Launching from console or notebook?
  • SG version

train_params = { "max_epochs": 300, "warmup_mode": "linear_epoch_step", "warmup_initial_lr": 1e-6, "lr_warmup_steps": 1000, "lr_warmup_epochs": 0, "initial_lr": 2e-4, "lr_mode": "cosine", "cosine_final_lr_ratio": 0.1, "zero_weight_decay_on_bias_and_bn": True, "batch_accumulate": 1, "save_ckpt_epoch_list": [100, 200, 250], "loss": PPYoloELoss(use_static_assigner=False, num_classes=80, reg_max=16), "optimizer": "AdamW", "optimizer_params": {"weight_decay": 0.00001}, "ema": True, "ema_params": {"decay": 0.9997, "decay_type": "threshold"}, "mixed_precision": False, "sync_bn": True,

"valid_metrics_list": [
    DetectionMetrics(score_thres=0.1, top_k_predictions=300, num_cls=80, normalize_targets=True,
                     post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.01,
                                                                            nms_top_k=1000, max_predictions=300,
                                                                            nms_threshold=0.7))],
"metric_to_watch": 'mAP@0.50:0.95',
"greater_metric_to_watch_is_better": True}

setup_device(multi_gpu='DP', num_gpus=2)

trainer = Trainer(experiment_name="yolo_nas_l_coco", ckpt_root_dir="./out/sg_checkpoints_dir/") net = models.get(Models.YOLO_NAS_L, num_classes=80) trainer.train(model=net, training_params=train_params, train_loader=train_loader, valid_loader=valid_loader)


- Launching from VScode
- SG version = 3.7.1
JaehwanOh-R commented 5 months ago

@BloodAxe Additionally, if you let me know the output format of the YOLO-NAS Large model, it may be solved

AlbertoRomanRamosRodriguez commented 4 months ago

I'm having the same issue right now