question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'" for sample_with_gt_wrapper

See original GitHub issue

System: Windows Server 2012 Compiler (for Cython): Visual Studio 2015

2017-10-22 19:58:16.567423: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
2017-10-22 19:58:16.805144: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
2017-10-22 19:58:16.805139: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
2017-10-22 19:58:16.805218: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
    return fn(*args)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1306, in _run_fn
    status, run_metadata)
  File "C:\Program Files\Python36\lib\contextlib.py", line 88, in __exit__
    next(self.gen)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
         [[Node: pyramid_2/AnchorEncoder_3/PyFunc/_2611 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_13175_pyramid_2/AnchorEncoder_3/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\train\train.py", line 341, in <module>
    train()
  File ".\train\train.py", line 271, in train
    [input_image] + [final_box] + [final_cls] + [final_prob] + [final_gt_cls] + [gt] + [tmp_0] + [tmp_1] + [tmp_2] + [tmp_3] + [tmp_4])
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
    run_metadata_ptr)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
    options, run_metadata)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
         [[Node: pyramid_2/AnchorEncoder_3/PyFunc/_2611 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_13175_pyramid_2/AnchorEncoder_3/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

Caused by op 'pyramid_1/SampleBoxesWithGT/PyFunc', defined at:
  File ".\train\train.py", line 341, in <module>
    train()
  File ".\train\train.py", line 193, in train
    loss_weights=[0.2, 0.2, 1.0, 0.2, 1.0])
  File ".\train\..\libs\nets\pyramid_network.py", line 580, in build
    is_training=is_training, gt_boxes=gt_boxes)
  File ".\train\..\libs\nets\pyramid_network.py", line 253, in build_heads
    sample_rpn_outputs_with_gt(rois, rpn_probs[:, 1], gt_boxes, is_training=is_training)
  File ".\train\..\libs\layers\wrapper.py", line 132, in sample_with_gt_wrapper
    [tf.float32, tf.float32, tf.int32, tf.float32, tf.float32, tf.int32])
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\ops\script_ops.py", line 203, in py_func
    input=inp, token=token, Tout=Tout, name=name)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\ops\gen_script_ops.py", line 36, in _py_func
    name=name)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'
         [[Node: pyramid_1/SampleBoxesWithGT/PyFunc = PyFunc[Tin=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_BOOL], Tout=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_FLOAT, DT_INT32], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/cpu:0"](pyramid_1/AnchorDecoder/Reshape/_2661, pyramid_1/strided_slice_8/_2663, random_shuffle_queue_Dequeue:3, pyramid_1/SampleBoxesWithGT/PyFunc/input_3)]]
         [[Node: pyramid_2/AnchorEncoder_3/PyFunc/_2611 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_13175_pyramid_2/AnchorEncoder_3/PyFunc", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
mengcz13commented, Oct 23, 2017

Fixed by changing line 25 of cpu_num.pyx from

cdef np.ndarray[np.int_t, ndim=1] order = scores.argsort()[::-1]

to

cdef np.ndarray[np.intp_t, ndim=1] order = scores.argsort()[::-1]

I am having some problems when compiling gpu_nms.pyx on Windows Server, and I am using cpu_nms. Still I don’t know what will happen if you use gpu_nms…

0reactions
rsqaicommented, Aug 1, 2020

把25行修改成如下: cdef np.ndarray[np.int_t, ndim=1] order = scores.argsort()[::-1].astype(‘int32’) 问题就解决了, 注意,一定要把之前编译的东西删干净再次编译

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cython: Buffer type mismatch, expected 'int' but got 'long'
You are using Cython's int type, which is just C int . I think on Mac (or most architectures) it is int 32-bit....
Read more >
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
I'm trying to fit a logistic regression on a sparse matrix, but I'm failing due to some ValueError: model = LogisticRegression( C=1, ...
Read more >
ValueError: Buffer dtype mismatch, expected 'long_t' but got ...
This error comes from cnp.long_t being different than the C Cython type identifier long. (with cimport numpy as cnp). Strangely, this error does ......
Read more >
ValueError: Buffer dtype mismatch, expected 'long' but got ...
I am trying to run test diagnostics on a trained model. The model throws an issue ValueError: Buffer dtype mismatch, expected 'long' but...
Read more >
Buffer dtype mismatch, expected 'Python object' but got 'long ...
ValueError : Buffer dtype mismatch, expected 'Python object' but got 'long long'. MaJeFi. Unladen Swallow. Posts: 2. Threads: 1.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found