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

Memory leak #8497

Open
jiajun-c opened this issue Mar 27, 2024 · 3 comments
Open

Memory leak #8497

jiajun-c opened this issue Mar 27, 2024 · 3 comments

Comments

@jiajun-c
Copy link

image

When variables are re-declared each time through the loop like below, the memory can not be released.

        z_temp = ti.Vector.field(3, dtype=ti.f32, shape=1000000) # the particle position
        zz_temp = ti.Vector.field(3, dtype=ti.f32, shape=1000000)

This code is well.

if __name__ == "__main__":
    while True:
        z_temp = ti.Vector.field(3, dtype=ti.f32, shape=1000000) # the particle position
        zz_temp = ti.Vector.field(3, dtype=ti.f32, shape=1000000)

This code is well too.

if __name__ == "__main__":
    with open("./data/scenes/demo_fluid_and_rigid.json", "r") as f:
        simulation_config = json.load(f)
    points, indices = getlines(simulation_config['configuration'])
    print(points)
    config = simulation_config['configuration']
    ps = particle_systemv4.ParticleSystemV4(simulation_config)
    # add fluid and rigid
    # ps.add_fluid_and_rigid()
    wcsph = WCSPHV2(ps)
    # wcsph.step()
    # wcsph.step()
    while True:
        for i in range(5):
            wcsph.step()

Whenever you merge these two codes, you will get a memory leak.

@jiajun-c
Copy link
Author

For each code, the memory usage of gpu is lower than 500MB, after merge them, the memory usage will be bigger than 24GB after some time steps.

@jiajun-c
Copy link
Author

Full code: git@github.com:jiajun-c/Ti-SPH.git

Branch: benchmark

command: python3 main_fluid_rigid.py

@jiajun-c
Copy link
Author

minimal code

import taichi as ti
ti.init(ti.cuda)

@ti.data_oriented
class Leaker:
    def __init__(self):
        pass
    
    @ti.kernel
    def foo(self):
        pass

@ti.kernel
def bar():
    pass

if __name__ == "__main__":
    # leaker = Leaker()
    while True:
        # leaker.foo()
        bar()
        print("11")
        # bugger = ti.Vector.field(3, dtype=ti.f32, shape=1000000) # the particle position
        bugger1 = ti.field(dtype=ti.i32, shape=1000000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant