Skip to content

VRAM leak during prompt processing #4946

Description

@Artefact2

I am using llama.cpp a836c8f, compiled on Arch Linux using make LLAMA_HIPBLAS=1 AMDGPU_TARGETS=gfx1030. My GPU is a RX 6750 XT.

I can reproduce a CUDA out of memory error when ingesting a long prompt with the following command:

./main -t 8 -f <(head -n420 wiki.train.raw) -c 24576 -n 1 -m ~/KoboldCpp/models/mixtral-instruct-8x7b-q4k-small.gguf

GGML_ASSERT: ggml-cuda.cu:231: !"CUDA error"
[New LWP 15195]
[New LWP 17341]
[New LWP 17342]
[New LWP 17343]
[New LWP 17344]
[New LWP 17345]
[New LWP 17346]
[New LWP 17347]

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.harting.dev>
  <https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
0x00007f6feb7181c7 in wait4 () from /usr/lib/libc.so.6
#0  0x00007f6feb7181c7 in wait4 () from /usr/lib/libc.so.6
#1  0x0000557f13db782b in ggml_print_backtrace ()
#2  0x0000557f13e7ff55 in ggml_cuda_error(char const*, char const*, char const*, int, char const*) ()
#3  0x0000557f13e8d6ff in ggml_cuda_pool_malloc_leg(int, unsigned long, unsigned long*) ()
#4  0x0000557f13eab3bc in cuda_pool_alloc<float>::alloc(unsigned long) ()
#5  0x0000557f13ea7d33 in ggml_cuda_op_mul_mat(ggml_tensor const*, ggml_tensor const*, ggml_tensor*, void (*)(ggml_tensor const*, ggml_tensor const*, ggml_tensor*, char const*, float const*, char const*, float*, long, long, long, long, ihipStream_t*), bool) [clone .181] ()
#6  0x0000557f13e80713 in ggml_cuda_compute_forward ()
#7  0x0000557f13de74e6 in ggml_graph_compute_thread ()
#8  0x0000557f13deb62d in ggml_graph_compute ()
#9  0x0000557f13ead75b in ggml_backend_cpu_graph_compute ()
#10 0x0000557f13eb1727 in ggml_backend_sched_graph_compute ()
#11 0x0000557f13e17df4 in llama_decode_internal(llama_context&, llama_batch) ()
#12 0x0000557f13e18ac6 in llama_decode ()
#13 0x0000557f13dabc49 in main ()

As I understand it, this shouldn't happen since the only VRAM that's being used is the BLAS scratch buffer, which is pre-allocated and around a gigabyte in size. However, VRAM use constantly goes up as the prompt is processed, up until it uses up all the VRAM of my card and crashes.

main.log

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions