Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mengcz13 opened this issue Oct 22, 2017 · 5 comments

Comments

@mengcz13
Copy link

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"]()]]
@mengcz13
Copy link
Author

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...

@Glimpse-006
Copy link

我把 np,int_t 修改为np.intp_t 后,问题还在
Evns:
Python37
numpy 1.16.3
window7

@hackerphysics
Copy link

我把 np,int_t 修改为np.intp_t 后,问题还在
Evns:
Python37
numpy 1.16.3
window7

我修改完之后问题也在,但是重新用 cython 编译,走那个 setup的流程后,问题就没了。

@Glimpse-006
Copy link

回复楼上,之前我也是修改后但是重新用 cython 编译,走那个 setup的流程,但是问题任然存在。
按照:
eragonruan/text-detection-ctpn#297
给的解决方法:
把25行修改成如下:
cdef np.ndarray[np.int_t, ndim=1] order = scores.argsort()[::-1].astype('int32')
问题解决了。

@rsqai
Copy link

rsqai commented Aug 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants