Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Got "kFlag == type_flag_: TBlob.get_with_shape: data type do not match specified type.Expected: 0 v.s. given 2" when training with amp. #18902

@kohillyang

Description

@kohillyang

Description

Hello, I'm trying to reproduce FCOS. In order to set a larger batch size, I'm trying to train my codes with FP16. I modified my codes based on https://github.com/dmlc/gluon-cv/blob/master/scripts/detection/faster_rcnn/train_faster_rcnn.py, but after training started, I got the following error. One possible reason is that I have used some Operators that AMP does not support, but all contrib operators I used are Deformable Convolution and BilinearResize2D, and I'm not sure if they are supported by AMP.

https://github.com/kohillyang/mx-detection/blob/master/scripts/train_fcos.py are my codes, Thanks.

Error Message

  0%|          | 0.00/19.5k [00:04<?, ?it/s]
Traceback (most recent call last):
  File "/data2/kohill/mx-detection/scripts/train_fcos.py", line 584, in <module>
    main()
  File "/data2/kohill/mx-detection/scripts/train_fcos.py", line 512, in main
    train_net(config)
  File "/data2/kohill/mx-detection/scripts/train_fcos.py", line 399, in train_net
    trainer.step(batch_size)
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/gluon/trainer.py", line 335, in step
    self._update(ignore_stale_grad)
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/contrib/amp/amp.py", line 321, in new_update
    self._old_update(ignore_stale_grad)
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/gluon/trainer.py", line 437, in _update
    updater(i, w, g)
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/optimizer/optimizer.py", line 2071, in __call__
    states)
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/contrib/amp/amp.py", line 313, in new_update_multi_precision
    if not skip_update():
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/contrib/amp/loss_scaler.py", line 64, in wait_and_update
    self._has_overflow = not bool(self.output.asnumpy())
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py", line 2535, in asnumpy
    ctypes.c_size_t(data.size)))
  File "/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/base.py", line 255, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [16:57:52] include/mxnet/././tensor_blob.h:215: Check failed: mshadow::DataType<DType>::kFlag == type_flag_: TBlob.get_with_shape: data type do not match specified type.Expected: 0 v.s. given 2
Stack trace:
  [bt] (0) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x6b8b5b) [0x7ffaebc7cb5b]
  [bt] (1) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x4295e78) [0x7ffaef859e78]
  [bt] (2) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x42c01d1) [0x7ffaef8841d1]
  [bt] (3) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(mxnet::imperative::PushFCompute(std::function<void (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&)> const&, nnvm::Op const*, nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<unsigned int, std::allocator<unsigned int> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&)::{lambda(mxnet::RunContext)#1}::operator()(mxnet::RunContext) const+0x307) [0x7ffaeee5d377]
  [bt] (4) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x37b68d4) [0x7ffaeed7a8d4]
  [bt] (5) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x37c4961) [0x7ffaeed88961]
  [bt] (6) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x37c7ea0) [0x7ffaeed8bea0]
  [bt] (7) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x37c8136) [0x7ffaeed8c136]
  [bt] (8) /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x37c3114) [0x7ffaeed87114]



Process finished with exit code 1

To Reproduce

(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)

Steps to reproduce

(Paste the commands you ran that produced the error.)

What have you tried to solve it?

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python

----------Python Info----------
Version      : 3.6.5
Compiler     : GCC 7.2.0
Build        : ('default', 'Apr 29 2018 16:14:56')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 10.0.1
Directory    : /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/pip
----------MXNet Info-----------
/data/kohill/anaconda3_jyw/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Version      : 1.6.0
Directory    : /data/kohill/anaconda3_jyw/lib/python3.6/site-packages/mxnet
Num GPUs     : 4
Commit Hash   : 6eec9da55c5096079355d1f1a5fa58dcf35d6752
----------System Info----------
Platform     : Linux-4.15.0-107-generic-x86_64-with-debian-stretch-sid
system       : Linux
node         : ubuntu
release      : 4.15.0-107-generic
version      : #108~16.04.1-Ubuntu SMP Fri Jun 12 02:57:13 UTC 2020
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                48
On-line CPU(s) list:   0-47
Thread(s) per core:    2
Core(s) per socket:    12
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 63
Model name:            Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
Stepping:              2
CPU MHz:               1735.211
CPU max MHz:           3300.0000
CPU min MHz:           1200.0000
BogoMIPS:              5001.81
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              30720K
NUMA node0 CPU(s):     0-11,24-35
NUMA node1 CPU(s):     12-23,36-47
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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts md_clear flush_l1d
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 10.0385 sec, LOAD: 8.7852 sec.
Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.0294 sec, LOAD: 9.1138 sec.
Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 5.0335 sec, LOAD: 22.5200 sec.
Timing for D2L: http://d2l.ai, DNS: 0.0282 sec, LOAD: 2.4723 sec.
Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.0285 sec, LOAD: 0.4769 sec.
Timing for FashionMNIST: https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 11.8055 sec, LOAD: 16.3673 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0289 sec, LOAD: 10.1921 sec.
Error open Conda: https://repo.continuum.io/pkgs/free/, HTTP Error 403: Forbidden, DNS finished in 0.02894139289855957 sec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions