Enable and Use External Initializers

Use shared external initializers to reduce memory usage by loading large model data once into global memory. You verify eligibility, enable sharing, monitor usage, and later disable it when no longer needed.

Before You Begin

Models must use external initializers to qualify for sharing. You can verify the model compatibility and proceed with the next steps. Administrators and data scientists must ensure their model import or conversion pipelines are designed accordingly, leveraging Oracle's OML4Py utilities or their own frameworks to export ONNX models with external initializers and associated metadata. See Support For Large ONNX Format Model Support for details on how to create models with external data.

Follow the steps to verify, enable, and use external initializers:

  1. Check that the ONNX model uses external initializers:
    SELECT model_name, EXTERNAL_DATA FROM all_mining_models;

    Only models with EXTERNAL_DATA=YES can be enabled for in-memory sharing.

  2. Enable in-memory sharing.
    EXECUTE DBMS_DATA_MINING.INMEMORY_ONNX_MODEL('your_model_name');

    This loads the initializers into shared memory. The INMEMORY status on the model view is set to YES.

  3. Monitor the model usage and memory.
    SELECT * FROM V$IM_ONNX_MODEL WHERE NAME = 'your_model_name';

    Shows metadata, population status, initializer sizes, and pin count. Inference in a session increments PIN_COUNT, displaying active usage of shared memory or many processes are sharing the model. If the session stops using the model for a while, the system decreases the pin count by one.

  4. Use V$IM_ONNX_SEGMENT for deeper insights for troubleshooting.
    SELECT * FROM V$IM_ONNX_SEGMENT WHERE NAME = 'your_model_name';
  5. Disable and release the memory.
    EXECUTE DBMS_DATA_MINING.INMEMORY_ONNX_MODEL('your_model_name', enable => FALSE);

    Note:

    The system releases the memory only after all sessions remove their pin.

See Also: