This application demonstrates how to import existing GXF Codelets and Components as Holoscan Operators/Resources. The example code is adapted from the Tensor interoperability example (examples/tensor_interop) and modified to illustrate the use of GXFCodeletOp and GXFComponentResource classes to import GXF Codelet/Component and customize the setup() and initialize() methods.
The main components include a set of custom operators that encapsulate GXF Codelets for sending and receiving tensors, and a resource class for managing block memory pools.
- GXFSendTensorOp: An operator that wraps a GXF Codelet responsible for sending tensors.
- GXFReceiveTensorOp: Extends
GXFCodeletOpto wrap a GXF Codelet that receives tensors, with customizable setup and initialization. - MyBlockMemoryPool: Represents a resource wrapping the
nvidia::gxf::BlockMemoryPoolGXF component, used to manage memory allocation.
- using deb package install or NGC container:
/opt/nvidia/holoscan/examples/import_gxf_components/cpp/import_gxf_components
- source (dev container):
./run launch # optional: append `install` for install tree ./examples/import_gxf_components/cpp/import_gxf_components - source (local env):
${BUILD_OR_INSTALL_DIR}/examples/import_gxf_components/cpp/import_gxf_components
Python example shows how to utilize the GXFCodeletOp and GXFComponentResource in a Holoscan application, focusing on video processing using custom and built-in operators.
- ToDeviceMemoryOp: A derived class from
GXFCodeletOpfor copying tensors to device memory. - ImageProcessingOp: Processes video frames using Gaussian filtering with CuPy.
- DeviceMemoryPool: Manages device memory allocations.
- using python wheel:
# [Prerequisite] Download NGC dataset above to `DATA_DIR` export HOLOSCAN_INPUT_PATH=<DATA_DIR> # [Prerequisite] Download example .py and .yaml file below to `APP_DIR` # [Optional] Start the virtualenv where holoscan is installed python3 -m pip install cupy-cuda12x python3 <APP_DIR>/import_gxf_components.py
- from NGC container:
python3 /opt/nvidia/holoscan/examples/import_gxf_components/python/import_gxf_components.py
- source (dev container):
./run launch # optional: append `install` for install tree python3 ./examples/import_gxf_components/python/import_gxf_components.py - source (local env):
python3 -m pip install cupy-cuda12x export PYTHONPATH=${BUILD_OR_INSTALL_DIR}/python/lib export HOLOSCAN_INPUT_PATH=${SRC_DIR}/data python3 ${BUILD_OR_INSTALL_DIR}/examples/import_gxf_components/python/import_gxf_components.py