Lightning-AI / Lightning-AI/lit-llama

Unable to run inference on multiple GPUs

Open
#347 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement inference
Dominant language
Python
Stars
6.1k
Forks
517
PR merge metrics
No merged PRs in 30d

Description

When I try to run the inference (using the generate.py file), I am unable to do so using multiple GPUs. I tried with 7B model, it works fine on one GPU, but the same model doesn't run when I set 'devices=4' which is strange (unless I'm doing something wrong, I just set 'devices=4' followed by fabric.launch()). Ultimately I want to run bigger models using all GPUs but I'm unable to get the smallest one running (which runs fine on a single GPU). My rig has 4 NVIDIA A10G GPUs, each with 23028 MiB memory (as per nvidia-smi).
The error I get is following:
'''
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 12.55 GiB (GPU 2; 22.02 GiB total capacity; 12.55 GiB already allocated; 8.76 GiB free; 12.55 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
'''
The error is repeated 4 times, I assume once for each GPU.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with generate.py and the devices=4 followed by fabric.launch() setup, then reproduce the 7B inference attempt on the four NVIDIA A10G GPUs. Inspect the repeated PyTorch CUDA out-of-memory errors and verify that multi-GPU inference completes without exceeding per-GPU memory.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.