[BUG] Memory leak in Cholesky decomposition (CUDA)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- cpp
- Bereich
- hpc, performance
Rechercherichtung
Beginne damit, den bereitgestellten C++-Reproducer auszuführen und den von af::choleskyInPlace verwendeten CUDA-Pfad zu untersuchen, insbesondere dessen Interaktion mit cuSolver und thread-lokalen Allokationen. Vergleiche den GPU-Speicher bei wiederholter Erstellung und beim Joinen von Threads; abgeschlossen ist die Aufgabe, wenn die wiederholten Aufrufe nach der Bereinigung nicht mehr ungefähr 40MB zusätzlichen Speicher pro Thread verbrauchen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
We experienced a gradual decrease of free GPU memory over time, which we pinned down to the Cholesky decomposition. Because of our architecture, this calculation occasionally ends up running in a new thread, each time causing thread-local allocations to be repeated over and over, eventually exhausting memory (40MB allocation per thread).
Description
Our software runs a number of services in different threads. Occasionally, the software will destroy these threads and create new ones. We run ArrayFire in one of these threads. We noticed that, each time after our software destroys and re-creates threads, GPU memory usage increases and never goes down. After a series of such destroy/re-create, GPU memory becomes clogged.
We pinned down this allocation in af::choleskyInPlace, i.e., likely inside cuSolver.
Reproducible Code and/or Steps
The code below reproduces the problem. Each thread allocates an extra 40MB of GPU memory, which is never released even after the thread is joined.
#include <arrayfire.h>
#include <cuda_runtime.h>
#include <iostream>
#include <thread>
std::size_t available_mem()
{
std::size_t free = 0;
std::size_t total = 0;
cudaMemGetInfo(&free, &total);
return free;
}
int main()
try
{
af::info();
std::size_t init_mem = available_mem();
for (std::size_t i = 0; i < 10; ++i)
{
std::thread t(
[&]()
{
af::array x = af::randu(40, 10);
af::array l = af::matmulTN(x, x);
x = af::array();
af::eval(l);
af::deviceGC();
if (af::choleskyInPlace(l, false) != 0)
{
std::cout << "bad" << std::endl;
return;
}
af::eval(l);
l = af::array();
af::deviceGC();
std::cout << "consumed: " << (init_mem - available_mem()) / 1024.0 / 1024.0 << std::endl;
});
t.join();
}
return 0;
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
return 1;
}
Output:
consumed: 50
consumed: 90
consumed: 130
consumed: 172
consumed: 212
consumed: 252
consumed: 294
consumed: 334
consumed: 374
consumed: 416
System Information
- ArrayFire version: 3.8.3
- Devices installed on the system: Nvidia GTX 1070 8GB
- (optional) Output from the af::info() function if applicable.
-
ArrayFire v3.8.3 (CUDA, 64-bit Windows, build 987d5675a) Platform: CUDA Runtime 11.8, Driver: 13000 [0] NVIDIA GeForce GTX 1070, 8192 MB, CUDA Compute 6.1 - ...
Checklist
- Using the latest available ArrayFire release
- GPU drivers are up to date
- Vorherrschende Sprache
- C++
- Sterne
- 4.9k
- Forks
- 555
- Ø Merge
- 1 Std. 24 Min.
- Gemergte PRs (30 T.)
- 1
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus arrayfire/arrayfire
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
Alle Issues in arrayfire/arrayfire
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Component: GLib
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
brave/brave-browser#59300 ·
-
Mute ydb/tests/functional/dstool/test_canonical_requests.py.Test.test_group_take_snapshot in main Offenai_reviewed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
ydb-platform/ydb#53974 · 3 Kommentare ·