Skip to content

Commit

Permalink
Support serving in container without tensorflow, torch, or cudf (
Browse files Browse the repository at this point in the history
…#326)

* Enable ensemble to run in container without tensorflow installed

* Check if cudf is available in convert_format

* Support Triton runtime with torch op in env without torch package

* Use tensorflow/torch imports from merlin.core.compat

---------

Co-authored-by: Karl Higley <[email protected]>
  • Loading branch information
oliverholworthy and karlhigley authored Apr 13, 2023
1 parent 386ef22 commit da739e2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions merlin/systems/dag/ops/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import os

import numpy as np
import torch
import torch.utils.dlpack

from merlin.core.compat.torch import torch
from merlin.core.protocols import Transformable
from merlin.dag import ColumnSelector
from merlin.schema import Schema
Expand Down
3 changes: 1 addition & 2 deletions merlin/systems/dag/ops/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# this needs to be before any modules that import protobuf
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

import tensorflow as tf # noqa

from merlin.core.compat.tensorflow import tensorflow as tf # noqa
from merlin.core.protocols import Transformable # noqa
from merlin.dag import ColumnSelector # noqa
from merlin.schema import ColumnSchema, Schema # noqa
Expand Down
2 changes: 1 addition & 1 deletion merlin/systems/triton/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def convert_format(tensors, kind, target_kind):
elif kind == Supports.GPU_DATAFRAME:
return _cudf_to_array(tensors, True), Supports.CPU_DICT_ARRAY

elif target_kind & Supports.GPU_DATAFRAME:
elif cudf and target_kind & Supports.GPU_DATAFRAME:
if kind == Supports.CPU_DATAFRAME:
return cudf.DataFrame(tensors), Supports.GPU_DATAFRAME
return _array_to_cudf(tensors), Supports.GPU_DATAFRAME
Expand Down

0 comments on commit da739e2

Please sign in to comment.