Skip to content

Python backend BLS unable to handle response from GPU model #3992

Description

@zeruniverse

Description

I have model A and model B, both in GPU. I wrote a BLS like this:

def execute(data):
 response = request(A, data).exec() # this gives me a probability
 if response['output'].as_numpy()[1] < 0.3:  # this line will fail.
  # model A cannot handle this case well, let's use model B
  return request(B, data).exec()
 return response

The failure is from this line https://github.com/triton-inference-server/python_backend/blob/56727b5b78d5d04720eac718c5f3ef1b9d591a94/src/pb_tensor.cc#L501

I think AsNumpy should be implemented no matter if the tensor is in CPU or GPU, otherwise, many BLS with multiple models (and conditions handling in Python) will fail.

Triton Information
Official 22.02

To Reproduce

See description

Expected behavior

If tensor is in CPU, as_numpy should just return the numpy array. Otherwise, tensor should be copied from GRAM to RAM and a Python object would own this copied numpy array

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions