Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Possible memory leak when merging DataFrames #3848

Closed
ayushdg opened this issue Jan 21, 2020 · 3 comments · Fixed by #3850
Closed

[BUG] Possible memory leak when merging DataFrames #3848

ayushdg opened this issue Jan 21, 2020 · 3 comments · Fixed by #3850
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@ayushdg
Copy link
Member

ayushdg commented Jan 21, 2020

Describe the bug
There might be a possible memory leak (or gc weirdness) when merging two DataFrames.

Steps/Code to reproduce bug

import cudf
import numpy as np
n_elem = 100_000_000

def func(n_elem):
    a = cudf.DataFrame({"a": np.arange(n_elem), "b": np.random.randint(0, 5, n_elem)})

    b = cudf.DataFrame(
        {
            "a": np.arange(
                n_elem - int(n_elem / 10), stop=2 * n_elem - int(n_elem / 10)
            ),
            "c": np.random.randint(0, 5, n_elem),
        }
    )

    a = a.merge(b, on="a", how="inner")
    return None

x1 = func(n_elem=n_elem)
x2 = func(n_elem=n_elem)

Memory usage after calling func (which returns None) with 0.12: 6.5GB
Memory usage after calling func with 0.11: 340 MB

Expected behavior
Similar memory usage with both versions.

Environment overview (please complete the following information)

  • Environment location: Docker
  • Method of cuDF install: 0.11 release docker, 0.12 from source at: adabc0e

Additional context
For v0.12, an arbitrary number of operations later the extra memory gets freed. If I explicitly call gc.collect() the memory gets freed.

When running func in a loop (tested on 10 iterations), it occasionally works with memory usage peaking around ~13-14GB and occasionally fails with OOM errors.

With 0.11 GPU mem usage doesn't exceed ~3-4GB during this process.

@ayushdg ayushdg added bug Something isn't working Needs Triage Need team to review and classify labels Jan 21, 2020
@shwina
Copy link
Contributor

shwina commented Jan 21, 2020

The two big changes since 0.11 that affect merge are (1) the libcudf++ refactor and (2) implicit typecasting. Possibly a first step would be to compare the behaviour of the following:

  1. cudf 0.11
  2. cudf 0.11 + libcudf++ refactor
  3. cudf 0.11 + libcudf++ refactor + implicit typecasting

cc: @brandon-b-miller @kkraus14

@brandon-b-miller
Copy link
Contributor

Looking into this on my side.

@brandon-b-miller
Copy link
Contributor

I think this is related the the fact that casting_rules within _typecast_before_merge is persisting references to the mergees, working on a PR.

@kkraus14 kkraus14 added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants