localGPT icon indicating copy to clipboard operation
localGPT copied to clipboard

GPU not utilized

Open stavsap opened this issue 1 year ago • 2 comments

Hi,

i am running with 3090 but it seems still it uses CPU.

in the log i see "Running on: cuda" but examining the resource usage the GPU is almost untouched.

what might be the issue?

i am running with "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"

stavsap avatar Jun 09 '23 17:06 stavsap

try to see if replacing "device_map=1" by "device_map='auto'" changes something. With my version it returns then an out of memory error (but it uses the GPU)

lelapin123 avatar Jun 11 '23 19:06 lelapin123

With my version it returns then an out of memory error (but it uses the GPU)

@lelapin123 try adding max_memory={0: "15GB"} to the AutoModelForCausalLM.from_pretrained function, like this :

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map='auto',
    torch_dtype=torch.float16,
    low_cpu_mem_usage=True,
    trust_remote_code=True,
    max_memory={0: "15GB"}
)

I added it in #139

Tchekda avatar Jun 11 '23 22:06 Tchekda

seems to utilize GPU now, thanks

stavsap avatar Jun 13 '23 18:06 stavsap

sorry, where did you replace "device_map=1" by "device_map='auto'? I'm running into the same issue

anmolbyte avatar Dec 01 '23 15:12 anmolbyte

@stavsap @ajarang I have same issue, please advise how can I get it work? thanks

yirunwang avatar Dec 14 '23 02:12 yirunwang

this thread is outdated. Check to see if you have Cuda, llama, and visual studio cuda extensions installed properly

anmolbyte avatar Dec 18 '23 15:12 anmolbyte

If anyone stumbles on this topic and is on Windows, this is the solution: After you install all requirements, you have to explicitely install torch with cuda! That means do

pip3 uninstall torch torchvision torchaudio

and then

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 .

Make sure to use the right version of cuda for your graphics card!

Tobias-Schnier avatar Jan 23 '24 12:01 Tobias-Schnier