首页 > 解决方案 > grpc._channel._InactiveRpcError: _InactiveRpcError 的 RPC 终止于:status = StatusCode.INTERNAL

问题描述

这是一个 gRPC 服务和客户端 python 程序。运行客户端脚本后,它会抛出此错误。特别是我对使用 API/gRPC 很陌生。如果我知道可能是什么问题,那就太好了。安装了 gRPC 库和一些支持库。

即使服务器运行正常,通过 gRPC 的通信也会以 INTERNAL 错误状态代码终止。在本地主机上运行它。

return _end_unary_response_blocking(state, call, False, None)
  File "/home/mark/anaconda3/envs/custom-model-server/lib/python3.8/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INTERNAL
        details = "indices[0,350] = 1650751580 is not in [0, 30522)
         [[{{node tf_bert_for_sequence_classification/bert/embeddings/Gather}}]]"
        debug_error_string = "{"created":"@1629922773.170809502","description":"Error received from peer ipv4:127.0.0.1:8001","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"indices[0,350] = 1650751580 is not in [0, 30522)\n\t [[{{node tf_bert_for_sequence_classification/bert/embeddings/Gather}}]]","grpc_status":13}"
'''

标签: apigrpcgoogle-api-python-clientgrpc-python

解决方案


对此的解决方案是检查传递给函数的字节数组,并确保我们采用的长度是数组本身的长度而不是字节。所以我们能够做到:

dimensions = len(byte_array)//4

推荐阅读