py4dstem / py4dstem/py4DSTEM

ACOM crystal.orientation_plan GPU Memory Management

Open
#606 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
279
Forks
177
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
When creating an orientation plan within a crystal class with CUDA set to True, GPU memory is continuously filled. I have not been able to figure out a way to dump the GPU memory short of shutting down the kernel and restarting it. Thus when working with multiple crystal classes and detailed orientation plans, GPU resource management is a cumbersome.

To Reproduce
-Build crystal classes (I am doing so from cif files)
-Calculate structure factors
-Generate detailed orientation plans (with small angle_step_zone_axis values)
-If that does not fill up the GPU memory, I also ran into the out of memory error when matching experimental patterns to the generated plans

Expected behavior
-Maybe implement some kind of batching system where GPU can dump to system memory
-Implement way to forcibly clear GPU memory so parameters in generating orientation plan can be tweaked so as to not fill up GPU memory
-Dump GPU memory to system memory after orientation plan has been generated

py4DSTEM version
0.14.9
Python version
python3.11
Operating system
Linux on an HPC cluster
Interfacing with JupyterLab

GPU
If GPU related please provide:

  • CUDA driver - 535.154.05
  • Cuda Version 12.2
  • Cupy Version - 13.0.0

Screenshots
image
image
image

Additional context
Screenshots show extreme example of an orientation plan for illustration of issue

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Reproduce the CUDA-enabled orientation-plan and experimental-pattern matching workflows described in the issue, using the reported Python, py4DSTEM, CUDA, and CuPy versions, then trace where GPU memory remains allocated. Done means repeated plans and matching runs no longer exhaust GPU memory and a documented cleanup or batching behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.