Skip to content

[BUG]: StridedMemoryView leaks the producer memory #1043

@pijyoi

Description

@pijyoi

Is this a duplicate?

Type of Bug

Something else

Component

cuda.core

Describe the bug

Obtaining a StridedMemoryView appears to prevent the producer array from being released.

How to Reproduce

Running the following script will throw an out of memory error:

cupy.cuda.memory.OutOfMemoryError: Out of memory allocating 1,073,741,824 bytes (allocated so far: 3,221,225,472 bytes).
from cuda.core.experimental.utils import StridedMemoryView

import cupy as xp

for idx in range(1000):
    print(idx)
    arr = xp.zeros((1024, 1024, 1024), dtype=xp.uint8)
    view = StridedMemoryView(arr, stream_ptr=-1)

Conversely, the following runs to completion

import cupy as xp

for idx in range(1000):
    print(idx)
    arr = xp.zeros((1024, 1024, 1024), dtype=xp.uint8)

Expected behavior

The script should run to completion.

Operating System

No response

nvidia-smi output

No response

Metadata

Metadata

Assignees

Labels

P0High priority - Must do!bugSomething isn't workingcuda.coreEverything related to the cuda.core module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions