Cupy: fft memory leakage

Created on 15 Nov 2020  路  3Comments  路  Source: cupy/cupy

cupy-cuda101 8.1.0; Window 10; Python 3.7.7

cupy.fft.fft and probably also other cupy.fft fuctions cause memory leakage. I can reproduce this bug with the following code:

import cupy as cp


t = cp.linspace(0, 1, 1000)
print("t      :", cp.get_default_memory_pool().used_bytes()/1024, "kB")

a = cp.sin(4 * t*2*3.1415)

print("t+a    :", cp.get_default_memory_pool().used_bytes()/1024, "kB")

fft = cp.fft.fft(a)

print("fft    :", fft.nbytes/1024, "kB")
print("t+a+fft:", cp.get_default_memory_pool().used_bytes()/1024, "kB")

del fft
cp.get_default_memory_pool().free_all_blocks()
cp.get_default_pinned_memory_pool().free_all_blocks()

print("t+a    :", cp.get_default_memory_pool().used_bytes()/1024, "kB")

del t,a
print("       :", cp.get_default_memory_pool().used_bytes()/1024, "kB")

Output:

t      : 8.0 kB
t+a    : 16.0 kB
fft    : 15.625 kB
t+a+fft: 48.0 kB
t+a    : 32.0 kB
       : 16.0 kB

Most helpful comment

(On my cell so forgive my brevity) this is not a bug; this is expected behavior, as starting v8.0 we cache cuFFT plans by default. The plans are tied to some memory as workspace, so unless the plans are deleted/the cache is cleared, there will be some memory hold. Check out the doc at https://docs.cupy.dev/en/stable/reference/plan_cache.html#cupy.fft._cache.PlanCache and try disabling the cache.

All 3 comments

(On my cell so forgive my brevity) this is not a bug; this is expected behavior, as starting v8.0 we cache cuFFT plans by default. The plans are tied to some memory as workspace, so unless the plans are deleted/the cache is cleared, there will be some memory hold. Check out the doc at https://docs.cupy.dev/en/stable/reference/plan_cache.html#cupy.fft._cache.PlanCache and try disabling the cache.

This explains why I started to get this behavior after upgrading from an earlier version. Thanks for pointing that out!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kmaehashi picture kmaehashi  路  3Comments

kmaehashi picture kmaehashi  路  3Comments

eldaromer picture eldaromer  路  3Comments

ax3l picture ax3l  路  3Comments

quasiben picture quasiben  路  4Comments