Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

MobileNetV3Lite RuntimeError during backprop #58

Open
hasicx opened this issue Mar 18, 2024 · 0 comments · May be fixed by #59
Open

MobileNetV3Lite RuntimeError during backprop #58

hasicx opened this issue Mar 18, 2024 · 0 comments · May be fixed by #59

Comments

@hasicx
Copy link

hasicx commented Mar 18, 2024

🐛 Describe the bug

Training any of the MobileNetV3Lite models fails on a local copy of ImageNet. The error occurs during the first training batch. With early validation enabled, the initial validation stage succeeds, indicating that the issue is related to backpropagation.

To reproduce, start by following the installation guidelines to setup and activate a virtual environment.

  • Option 1: if using the training script, comment the uncommented lines, and uncomment the lines for one of the MobileNetV3Lite models. Then, start the training script using ./run_edgeailite_classification.sh.
  • Option 2: execute the following command directly.
    python3 ./references/edgeailite/main/classification/train_classification_main.py --dataset_name image_folder_classification --model_name mobilenetv3_lite_large_x1 \
    --data_path ./data/datasets/image_folder_classification --weight_decay 4e-5 --epochs 600 --batch_size 512 --lr 0.1 \
    --auto_augument imagenet --random_erasing 0.2
    

Below is the final section of the generated training log. The log includes a successful early validation, along with the traceback of the raised exception.

=> validation 0.00% of 1x98... rate=0 Hz, eta=?, total=0:00:00
=> validation 0.00% of 1x98... rate=0 Hz, eta=?, total=0:00:00
=> validation 0.00% of 1x98...Epoch=1/600 LR=0.00010 Time=16.664 Loss=6.908 Prec@1=0.000 Prec@5=0.391 rate=0 Hz, eta=?, total=0:00:00
** validation 1.02% of 1x98...Epoch=1/600 LR=0.00010 Time=16.664 Loss=6.908 Prec@1=0.000 Prec@5=0.391 rate=2173.11 Hz, eta=0:00:00, total=0:00:00
** validation 1.02% of 1x98...Epoch=1/600 LR=0.00010 Time=0.384 Loss=6.908 Prec@1=0.100 Prec@5=0.466 rate=2173.11 Hz, eta=0:00:00, total=0:00:00
** validation 100.00% of 1x98...Epoch=1/600 LR=0.00010 Time=0.384 Loss=6.908 Prec@1=0.100 Prec@5=0.466 rate=4.67 Hz, eta=0:00:00, total=0:00:20
[39m [37mTraceback (most recent call last):
  File "/src/edgeai-torchvision/references/edgeailite/main/classification/train_classification_main.py", line 206, in <module>
    train_classification.main(args)
  File "/src/edgeai-torchvision/references/edgeailite/edgeai_xvision/xengine/train_classification.py", line 427, in main
    train(args, train_loader, model, criterion, optimizer, epoch, grad_scaler)
  File "/src/edgeai-torchvision/references/edgeailite/edgeai_xvision/xengine/train_classification.py", line 578, in train
    loss.backward()
  File "/src/edgeai-torchvision/.venv/lib/python3.10/site-packages/torch/_tensor.py", line 487, in backward
    torch.autograd.backward(
  File "/src/edgeai-torchvision/.venv/lib/python3.10/site-packages/torch/autograd/__init__.py", line 200, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [256, 1280]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

Versions

PyTorch version: 2.0.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-94-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A40
GPU 1: NVIDIA A40

Nvidia driver version: 525.147.05
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.5.0
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
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Vendor ID: AuthenticAMD
Model name: AMD EPYC 7343 16-Core Processor
CPU family: 25
Model: 1
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 2
Stepping: 1
Frequency boost: enabled
CPU max MHz: 3940.6250
CPU min MHz: 1500.0000
BogoMIPS: 6399.81
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca
Virtualization: AMD-V
L1d cache: 1 MiB (32 instances)
L1i cache: 1 MiB (32 instances)
L2 cache: 16 MiB (32 instances)
L3 cache: 256 MiB (8 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-15,32-47
NUMA node1 CPU(s): 16-31,48-63
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Mitigation; safe RET
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] edgeai_torchmodelopt==9.1.0+c6958ab
[pip3] numpy==1.23.0
[pip3] onnx==1.13.0
[pip3] onnxsim==0.4.36
[pip3] torch==2.0.1+cu118
[pip3] torchinfo==1.8.0
[pip3] torchvision==0.15.2+cu118
[pip3] triton==2.0.0
[conda] Could not collect

@hasicx hasicx linked a pull request Mar 18, 2024 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant