hoffstadt / hoffstadt/DearPyGui

Very high GPU and RAM use when displaying image series

Open
#1,796 6 comments 0 reactions 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 1.6.2
Operating System: Windows 10

## My Issue/Question

I have noticed that when I display a texture the GPU usage in Task Manager is very high. I am displaying two textures (two PNG images of about 4MB each, though this also occurs with jpgs), and my GPU usage is about 90% (using a NVIDIA T1200 Laptop GPU).

The weirdest part is that if I am actively loading in new images, the GPU usage drops down to about 40%, but as soon as I stop loading new images in, the GPU goes to 90%.

Also, the frame-rate tanks to close to 20 FPS after the images have been loaded.

## To Reproduce

Steps to reproduce the behavior:
1. Create a DPG plot
2. Add a texture to the texture registry
3. Add the texture as an image series
4. Show the image series
5. Note the high GPU usage

## Expected behavior

DPG GPU usage would be high during loading and initial display, but lower after the image has been loaded.

## Screenshots/Video

![image](https://user-images.githubusercontent.com/32853381/172713296-e39dacd4-1194-4466-acde-e2e42186d218.png)

You can see before clicking load images, after, and then after the application is closed in this small graph.

![image](https://user-images.githubusercontent.com/32853381/172714010-6b2afc4e-868b-4e3d-bbc1-1744c45910cd.png)

## Standalone, minimal, complete and verifiable example

Here's the [image](https://unsplash.com/photos/Yj1M5riCKk4/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8Mnx8c3BhY2V8ZW58MHx8fHwxNjU0NjMzMzUy&force=true) I used. I renamed it to `nasa.jpg`.

```python
# Here's some code anyone can copy and paste to reproduce your issue
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title='Custom Title', width=1600, height=1000)

with dpg.window(label="View One", tag="view_one", min_size=(int(dpg.get_viewport_width()), dpg.get_viewport_height())):
dpg.add_plot(
tag=f"curr_image_plot_1",
height=-1,
width=-1,
crosshairs=True,
query=True,
equal_aspects=True,
)
dpg.add_plot_axis(label="Width",
axis=1,
tag=f"curr_image_plot_x_axis_1",
no_gridlines=False,
lock_min=False,
parent=f"curr_image_plot_1")
dpg.add_plot_axis(label="Height",
axis=2,
tag=f"curr_image_plot_y_axis_1",
no_gridlines=False,
lock_min=False,
parent=f"curr_image_plot_1")

def load_images():
width, height, _, data = dpg.load_image("nasa.jpg")
with dpg.texture_registry():
dpg.add_raw_texture(width=width, height=height, default_value=data, tag=f"test_texture")
dpg.add_image_series(f"test_texture", [0, 0], [width, height], parent=f"curr_image_plot_y_axis_1")
dpg.fit_axis_data(f"curr_image_plot_x_axis_1")
dpg.fit_axis_data(f"curr_image_plot_y_axis_1")
dpg.show_metrics()
dpg.hide_item("win_controls")

with dpg.window(label="Controls", autosize=True, tag="win_controls"):
dpg.add_button(label="Load Images", callback=load_images)

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
dpg.destroy_context()

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.