Apple M2 4.1 Metal Insufficient Memory issues
I am experiencing some sort of memory leak style situation on Apple M2 4.1 Metal getting this output/error and a failure to render after creating many plots:
2022-11-10 18:54:22.612 python[43029:22201890] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=8 "Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)" UserInfo={NSLocalizedDescription=Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)}
2022-11-10 18:54:22.612 python[43029:22245594] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=8 "Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)" UserInfo={NSLocalizedDescription=Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)}
2022-11-10 18:54:22.638 python[43029:22119884] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=8 "Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)" UserInfo={NSLocalizedDescription=Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)}
The following code reproduces the issue without fail for me:
import vtk
source = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
source = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
for i in range(1000):
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetOffScreenRendering(1)
renWin.AddRenderer(ren)
iren = vtk.vtkGenericRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(actor)
iren.Initialize()
renWin.Render()
iren.Start()
del iren, renWin
My sysyem information:
--------------------------------------------------------------------------------
Date: Thu Nov 10 18:55:03 2022 MST
OS : Darwin
CPU(s) : 8
Machine : arm64
Architecture : 64bit
RAM : 24.0 GiB
Environment : Jupyter
File system : apfs
GPU Vendor : Apple
GPU Renderer : Apple M2
GPU Version : 4.1 Metal - 76.3
Python 3.9.13 (main, Aug 25 2022, 18:24:45) [Clang 12.0.0 ]
vtk : 9.2.2
--------------------------------------------------------------------------------