test_plotting failures on M2 Mac due to memory issues
See original GitHub issueDescribe the bug, what’s wrong, and what you expected.
I’m seeing ~93 test failures in tests/plotting/test_plotting.py
on my M2 Mac.
I think all of them are raising the same error: RuntimeError: Unable to extract image from Plotter as it has already been closed.
from
Here is one of the test failures:
___________________________________ test_plot_points_gaussian_scalars ___________________________________
[gw3] darwin -- Python 3.9.13 /opt/miniconda3/envs/pyvista-dev/bin/python
sphere = PolyData (0x29ba6cb80)
N Cells: 840
N Points: 422
N Strips: 0
X Bounds: -1.260e+02, 1.250e+02
Y Bounds: -1.270e+02, 1.260e+02
Z Bounds: -1.270e+02, 1.270e+02
N Arrays: 2
@skip_windows
def test_plot_points_gaussian_scalars(sphere):
> sphere.plot(
scalars=sphere.points[:, 2],
style='points_gaussian',
render_points_as_spheres=False,
point_size=20,
opacity=0.5,
show_scalar_bar=False,
before_close_callback=verify_cache_image,
)
tests/plotting/test_plotting.py:3092:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyvista/plotting/helpers.py:302: in plot
return pl.show(
pyvista/plotting/plotting.py:6201: in show
self.close()
pyvista/plotting/plotting.py:4027: in close
self._before_close_callback(self)
tests/plotting/test_plotting.py:250: in verify_cache_image
error = pyvista.compare_images(image_filename, plotter)
pyvista/utilities/regression.py:131: in compare_images
im2 = remove_alpha(to_img(im2))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
img = <pyvista.plotting.plotting.Plotter object at 0x29e0c3190>
def to_img(img):
if isinstance(img, UniformGrid): # pragma: no cover
return img
elif isinstance(img, _vtk.vtkImageData):
return wrap(img)
elif isinstance(img, str):
return read(img)
elif isinstance(img, np.ndarray):
return wrap_image_array(img)
elif isinstance(img, Plotter):
if img._first_time: # must be rendered first else segfault
img._on_first_render_request()
img.render()
if not hasattr(img, 'ren_win'):
> raise RuntimeError(
'Unable to extract image from Plotter as it has already been closed.'
)
E RuntimeError: Unable to extract image from Plotter as it has already been closed.
pyvista/utilities/regression.py:120: RuntimeError
----------------------------------------- Captured stderr call ------------------------------------------
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
2022-10-14 12:17:18.079 python[82376:1047634] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=8 "Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)" UserInfo={NSLocalizedDescription=Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory)}
If I run with pytest -v -n 6 .
I see ~93 failures. If I run with pytest -v .
, I see ~82 failures. If I just run pytest -v tests/plotting/test_plotting.py
, I see ~21 failures.
This pattern makes me think there is a memory management issue or memory leak an eventually the plotting tests just start failing
Steps to reproduce the bug.
pytest -v .
On an M2 mac
System Information
--------------------------------------------------------------------------------
Date: Fri Oct 14 12:18:07 2022 MDT
OS : Darwin
CPU(s) : 8
Machine : arm64
Architecture : 64bit
RAM : 24.0 GiB
Environment : Python
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 ]
pyvista : 0.37.dev0
vtk : 9.2.2
numpy : 1.23.1
imageio : 2.22.1
appdirs : 1.4.4
scooby : 0.5.12
matplotlib : 3.6.1
IPython : 8.5.0
colorcet : 3.0.1
cmocean : 2.0
ipyvtklink : 0.2.3
scipy : 1.9.2
tqdm : 4.64.1
meshio : 5.3.4
jupyterlab : 3.4.8
pythreejs : Version unknown
--------------------------------------------------------------------------------
This is an Apple M2 chip with 8‑core CPU, 10‑core GPU, 24GB unified memory
Screenshots
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Common MacBook Air M2 problems and how to fix them
With the M2 MacBook Air out in the wild, here are some of the most common problems people are running into.
Read more >MAJOR PROBLEMS With the M2 MacBook Air - All The Issues
ALL THE ISSUES With the M2 MacBook Air.Is the MacBook Pro 16 M1 Max, M2 MacBook Pro 13 or M1 MacBook Air a...
Read more >“Your system has run out of application memory” Mac Error
“Your system as run out of application memory” is an error message encountered by some Mac users, often seemingly out of nowhere.
Read more >How to restore Mac run out of application memory - Setapp
Learn how to fix common application memory issues, manage memory usage, and free up disk space on your Mac.
Read more >Repair a storage device in Disk Utility on Mac - Apple Support
Disk Utility can check for and fix errors related to the formatting and directory structure of a Mac storage device. Disk Utility can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The test suite ran without any issues with a bit more than 9 GB of free RAM. The memory monitor graph barely increased during the run. The largest memory use estimate from pytest is 210 MB, and even if I add up all the numbers above 1 MB (which gives a nonsensical upper bound) I get 5.2 GB. This is just to confirm that it is extremely unlikely that you are actually running out of RAM.
My laptop (running linux) has 16 gigs total and I can usually run the test suite fine. I’ll check later tonight. I’d expect this to be some memory allocation bug on the weird M2 rather than an actual pyvista bug.