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

OOM Llama 3.2-11B on RTX 4090 #1341

Open
byjlw opened this issue Nov 2, 2024 · 1 comment
Open

OOM Llama 3.2-11B on RTX 4090 #1341

byjlw opened this issue Nov 2, 2024 · 1 comment
Labels
bug Something isn't working performance

Comments

@byjlw
Copy link
Contributor

byjlw commented Nov 2, 2024

🐛 Describe the bug

torchchat will OOM when using the Llama 3.2 11b model almost right away. If it doesn't OOM on the first request it will on the second.

When spinning up the server it'll immediately take 22GB of memory (expected)

First request will take it close to the 24GB limit or over in some cases.
Second request will definitely will

Instructions

python3 torchchat.py server llama3.2-11B

streamlit run torchchat/usages/browser.py

Add an image and provide a prompt

Output

2024-11-02:13:30:48,748 INFO     [_internal.py:97] Press CTRL+C to quit
 === Completion Request ===
This2024-11-02:13:32:18,977 INFO     [_internal.py:97] 127.0.0.1 - - [02/Nov/2024 13:32:18] "POST /v1/chat/completions HTTP/1.1" 200 -
 image shows a large spaceship on a barren planet with three astronauts in the foreground. One astronaut is carrying what looks like a dolly. In the background, there is another spaceship that looks like ruins and two large moons. The overall mood is creepy, with the astronauts in spacesuits and the desolate surroundings. === Completion Request ===
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,311 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,345 INFO     [_internal.py:97] 127.0.0.1 - - [02/Nov/2024 13:33:45] "POST /v1/chat/completions HTTP/1.1" 500 -
2024-11-02:13:33:45,348 ERROR    [_internal.py:97] Error on request:
Traceback (most recent call last):
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 370, in run_wsgi
    execute(self.server.app)
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 333, in execute
    for data in application_iter:
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wsgi.py", line 256, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
    for item in iterable:
  File "/home/warden/source/torchchat/torchchat/usages/server.py", line 77, in chunk_processor
    for chunk in chunked_completion_generator:
  File "/home/warden/source/torchchat/torchchat/usages/openai_api.py", line 392, in chunked_completion
    for y, _ in self.generate(
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    response = gen.send(None)
               ^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 645, in generate
    next_token = self.prefill(
                 ^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 382, in prefill
    logits = model(
             ^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/model.py", line 568, in forward
    return self.model(
           ^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/model_fusion/_fusion.py", line 446, in forward
    encoder_embed = self.encoder(**encoder_input)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/models/llama3_2_vision/_encoder.py", line 123, in forward
    x, hidden_states = self.clip(images, aspect_ratio)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/vision_transformer.py", line 389, in forward
    x = transformer_layer(x)
        ^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/transformer.py", line 120, in forward
    mlp_out = self.mlp(self.mlp_norm(h))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/feed_forward.py", line 50, in forward
    h = self.activation(self.w1(x))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/activation.py", line 734, in forward
    return F.gelu(input, approximate=self.approximate)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 126.00 MiB. GPU 0 has a total capacity of 23.52 GiB of which 40.31 MiB is free. Including non-PyTorch memory, this process has 22.79 GiB memory in use. Of the allocated memory 21.99 GiB is allocated by PyTorch, and 333.12 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
 === Completion Request ===
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,872 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:45,893 INFO     [_internal.py:97] 127.0.0.1 - - [02/Nov/2024 13:33:45] "POST /v1/chat/completions HTTP/1.1" 500 -
2024-11-02:13:33:45,894 ERROR    [_internal.py:97] Error on request:
Traceback (most recent call last):
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 370, in run_wsgi
    execute(self.server.app)
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 333, in execute
    for data in application_iter:
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wsgi.py", line 256, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
    for item in iterable:
  File "/home/warden/source/torchchat/torchchat/usages/server.py", line 77, in chunk_processor
    for chunk in chunked_completion_generator:
  File "/home/warden/source/torchchat/torchchat/usages/openai_api.py", line 392, in chunked_completion
    for y, _ in self.generate(
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    response = gen.send(None)
               ^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 645, in generate
    next_token = self.prefill(
                 ^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 382, in prefill
    logits = model(
             ^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/model.py", line 568, in forward
    return self.model(
           ^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/model_fusion/_fusion.py", line 446, in forward
    encoder_embed = self.encoder(**encoder_input)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/models/llama3_2_vision/_encoder.py", line 123, in forward
    x, hidden_states = self.clip(images, aspect_ratio)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/vision_transformer.py", line 381, in forward
    x = self.ln_pre(x)
        ^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/layer_norm.py", line 30, in forward
    output = nn.functional.layer_norm(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/functional.py", line 2910, in layer_norm
    return torch.layer_norm(
           ^^^^^^^^^^^^^^^^^
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 64.00 MiB. GPU 0 has a total capacity of 23.52 GiB of which 38.31 MiB is free. Including non-PyTorch memory, this process has 22.80 GiB memory in use. Of the allocated memory 22.10 GiB is allocated by PyTorch, and 221.32 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
 === Completion Request ===
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,010 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,011 WARNING  [attention.py:156] Key value caches are already setup. You cannot call ``setup_caches()`` twice. Skipping.
2024-11-02:13:33:47,031 INFO     [_internal.py:97] 127.0.0.1 - - [02/Nov/2024 13:33:47] "POST /v1/chat/completions HTTP/1.1" 500 -
2024-11-02:13:33:47,032 ERROR    [_internal.py:97] Error on request:
Traceback (most recent call last):
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 370, in run_wsgi
    execute(self.server.app)
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/serving.py", line 333, in execute
    for data in application_iter:
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wsgi.py", line 256, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
    for item in iterable:
  File "/home/warden/source/torchchat/torchchat/usages/server.py", line 77, in chunk_processor
    for chunk in chunked_completion_generator:
  File "/home/warden/source/torchchat/torchchat/usages/openai_api.py", line 392, in chunked_completion
    for y, _ in self.generate(
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    response = gen.send(None)
               ^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 645, in generate
    next_token = self.prefill(
                 ^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/generate.py", line 382, in prefill
    logits = model(
             ^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/torchchat/model.py", line 568, in forward
    return self.model(
           ^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/model_fusion/_fusion.py", line 446, in forward
    encoder_embed = self.encoder(**encoder_input)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/models/llama3_2_vision/_encoder.py", line 123, in forward
    x, hidden_states = self.clip(images, aspect_ratio)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/vision_transformer.py", line 381, in forward
    x = self.ln_pre(x)
        ^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torchtune/modules/layer_norm.py", line 30, in forward
    output = nn.functional.layer_norm(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/warden/source/torchchat/.venv/lib/python3.11/site-packages/torch/nn/functional.py", line 2910, in layer_norm
    return torch.layer_norm(
           ^^^^^^^^^^^^^^^^^
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 64.00 MiB. GPU 0 has a total capacity of 23.52 GiB of which 38.31 MiB is free. Including non-PyTorch memory, this process has 22.80 GiB memory in use. Of the allocated memory 22.10 GiB is allocated by PyTorch, and 222.14 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

Versions

Collecting environment information...
PyTorch version: 2.6.0.dev20241002+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.1 LTS (x86_64)
GCC version: (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Clang version: Could not collect
CMake version: version 3.30.5
Libc version: glibc-2.39

Python version: 3.11.10 (main, Sep 7 2024, 18:35:41) [GCC 13.2.0] (64-bit runtime)
Python platform: Linux-6.8.0-48-generic-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 12.6.77
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version: 560.35.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Vendor ID: AuthenticAMD
Model name: AMD Ryzen 9 7950X3D 16-Core Processor
CPU family: 25
Model: 97
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 1
Stepping: 2
CPU(s) scaling MHz: 29%
CPU max MHz: 5759.0000
CPU min MHz: 545.0000
BogoMIPS: 8400.06
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d
Virtualization: AMD-V
L1d cache: 512 KiB (16 instances)
L1i cache: 512 KiB (16 instances)
L2 cache: 16 MiB (16 instances)
L3 cache: 128 MiB (2 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Mitigation; Safe RET
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-cupti-cu12==12.1.105
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.0.2.54
[pip3] nvidia-curand-cu12==10.3.2.106
[pip3] nvidia-cusolver-cu12==11.4.5.107
[pip3] nvidia-cusparse-cu12==12.1.0.106
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] pytorch-triton==3.1.0+cf34004b8a
[pip3] torch==2.6.0.dev20241002+cu121
[pip3] torchao==0.5.0
[pip3] torchtune==0.4.0.dev20241010+cu121
[pip3] torchvision==0.20.0.dev20241002+cu121

@Jack-Khuu Jack-Khuu added bug Something isn't working performance labels Nov 12, 2024
@Jack-Khuu
Copy link
Contributor

Thanks for the flag, this'll be a good snapshot as we work on quant/reducing overhead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance
Projects
None yet
Development

No branches or pull requests

2 participants