Skip to content

#ARRUS-543: Added GPU prototxt setting to enable customisation of MemoryPool Usage and RAM Limit for ProcessingRunner#428

Open
pjarosik wants to merge 7 commits intov0.14.xfrom
ref-ARRUS-543
Open

#ARRUS-543: Added GPU prototxt setting to enable customisation of MemoryPool Usage and RAM Limit for ProcessingRunner#428
pjarosik wants to merge 7 commits intov0.14.xfrom
ref-ARRUS-543

Conversation

@pjarosik
Copy link
Collaborator

@pjarosik pjarosik commented Jan 22, 2026

This is a follow-up PR based on the submission prepared by @gordon-n-stevenson; the original PR can be found here.

Many thanks to @gordon-n-stevenson! Original description:

When using arrus with other GPU applications on a device, the use of the default mempool can lead to the arrus instances taking more and more memory if set_scheme is used over and over.

In cases where other processes are using the GPU, this cause issues with memory management as cupy seems to avoid freeing up all the GPU memory for other processes.

While env_var variables can be used to limit all cupy processes on the device, this PR adds a couple of params to the ARRUS prototxt so that ultrasound imaging alone can be memory managed by the user without having to do global adjustment of memory limits.

Another approach would be to remove memory pooling entirely but I think this approach should provide flexibility for all development, providing the ability to add it on/off and also set a hard limit for the GPU memory when using ARRUS.

This was tested and built on arrus v0.11.0 and successfully ran by monitoring changes to different schemes running different doppler and bmode schemes then monitoring the GPU usage by using nvtop

I have introduced the following changes compared to the base PR:

  1. I moved GpuSettings from Us4RSettings to SessionSettings, as the GPU can be treated as a device independent of the connected Us4R. This results in the following changes:
  • In the .prototxt file: the gpu settings should be defined at the top-level of the entire file (previously they were part of us4r settings) see e.g., these test .prototxt
  • C++ API: SessionBuilder now has an additional method addGpu.
  1. GpuSettings is now immutable (setters have been removed).
  2. The logging level for GPU information has been restored to INFO (in accordance with other users’ requirements).

"""
Set the GPU memory limit for the memory pool as a percentage of total GPU memory.

:param gpu_memory_limit_percentage: Percentage of total GPU memory to use (0.0 to 1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is following line in the docs/content/user_guide.python.rst:
'
The memory_limit_percentage is the percentage of the GPU memory that should be used by the memory pool. Values between 0.01 and 0.95 are allowed.
'
Here is " (0.0 to 1.0)".
Is it inconsistency or these are other things?

# Here starts communication with the device.
medium = arrus.medium.Medium(name="water", speed_of_sound=1490)
with arrus.Session("us4r.prototxt", medium=medium) as sess:
with arrus.Session("/home/pjarosik/us4r.prototxt", medium=medium) as sess:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the recent path was better for the example.

)

arrus.set_clog_level(arrus.logging.INFO)
arrus.set_clog_level(arrus.logging.DEBUG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need debug level here in the example script?

sample_range=(0, 4096),
delays=[0]*n_elements),
Rx(aperture=np.ones(n_elements).astype(bool),
sample_range=[420, 420+512],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is example script - it would be 'more naturally' (probably) if sample range would be rather larger, like [0, 1024], to be ready to see 'the wire in the water' or similar simple object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants