DearPyGui
DearPyGui copied to clipboard
Very high GPU and RAM use when displaying image series
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:
- Create a DPG plot
- Add a texture to the texture registry
- Add the texture as an image series
- Show the image series
- 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

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

Standalone, minimal, complete and verifiable example
Here's the image I used. I renamed it to nasa.jpg.
# 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()
Another issue I noticed with this is that the RAM usage is very high at over 2GB to display this image. I do not know where that RAM requirement could be coming from.

perhaps related to #1109
I had an issue opening my images at all so I used pillow and numpy to load them:
def add_static_image(filename, width, height, *args, **kwargs):
with importlib.resources.path(images, filename) as img_file:
try:
width, height, _, data = dpg.load_image(img_file)
except SystemError:
warn(
"DearPyGUI load_image failed. Trying PIL Image.open...",
stacklevel=2,
)
image = Image.open(img_file).resize((width, height))
# width, height = image.size
data = np.frombuffer(image.tobytes(), dtype=np.uint8) / 255.0
dpg.add_static_texture(
width,
height,
data,
*args,
# format=dpg.mvFormat_Float_rgba,
**kwargs,
)
Try this instead of dpg.load_image:
image = Image.open(img_file).resize((width, height))
width, height = image.size
data = np.frombuffer(image.tobytes(), dtype=np.uint8) / 255.0
@keck-in-space I saw you work at NASA. I’m now working at NASA (JSC) as a contractor. Are you on the DPG discord channel?
@krister-ts and this fixed the ram issue?
@krister-ts and this fixed the ram issue?
Never actually had dpg work for my images...
EDIT:
I mean the load_image function from DearPyGui to be more clear
@hoffstadt Awesome! Welcome to NASA! I am not on the Discord channel... I don't use Discord for privacy reasons since it is closed source owned by Tencent. Just my opinion lol.