Skip to content

VMD causes excessive memory usage for long signals due to storing all iteration results #53

Description

@liwenchao36

Description

When using PySDKit.VMD on a relatively long time series, the VMD implementation attempts to allocate a very large amount of memory and raises a numpy.core._exceptions._ArrayMemoryError.

The main source of the memory usage seems to be this allocation in pysdkit/_vmd/vmd_c.py:

u_hat_plus = np.zeros(
    [self.max_iter, len(freqs), self.K],
    dtype=complex
)

This stores the frequency-domain modes for all iterations.
For long signals, the memory requirement becomes very large because its complexity is approximately:
O(max_iter * signal_length * K)

Example

For my data:
Original signal length: ~265,140
Mirrored signal length / len(freqs): 530,280
max_iter: 500
K: 8
dtype: complex128

PySDKit tries to allocate:
shape = (500, 530280, 8)

which requires about:
31.6 GiB

Full traceback:
File ".../pysdkit/_vmd/vmd_c.py", line 186, in fit_transform
    u_hat_plus = np.zeros([self.max_iter, len(freqs), self.K], dtype=complex)

numpy.core._exceptions._ArrayMemoryError:
Unable to allocate 31.6 GiB for an array with shape
(500, 530280, 8) and data type complex128

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions