Contenu principal

releaseGPUMemory

R2026b

Release GPU memory allocated for model

Since R2026b

    Description

    Add-On Required: This feature requires the Computer Vision Toolbox Model for Apple DepthPro Network add-on.

    releaseGPUMemory(depthModel) releases the GPU memory allocated to the depth estimation model object depthModel.

    Use this function to free GPU resources after estimating depth maps on a GPU by using the estimateDepth function. After you call releaseGPUMemory, the model reloads automatically when you call estimateDepth again. The model loads onto the execution device specified by the ExecutionEnvironment name-value argument.

    example

    Examples

    collapse all

    Load a pretrained Depth Pro model for estimating depth.

    depthModel = depthpro;

    Read an image into the MATLAB® workspace.

    img = imread("office_6.jpg");

    Estimate the depth map and the inferred focal length by using the estimateDepth function of the depthpro object.

    depthMap = estimateDepth(depthModel,img,ExecutionEnvironment="gpu");

    When you set ExecutionEnvironment to "gpu", the model uses the GPU for inference and remains there after estimateDepth returns. By default, ExecutionEnvironment is set to "auto", which automatically uses a GPU when one is available. To clear the GPU memory cache and prevent memory issues, call releaseGPUMemory after estimating the depth map.

    releaseGPUMemory(depthModel);

    Input Arguments

    collapse all

    Depth estimation model, specified as a depthpro object.

    Version History

    Introduced in R2026b