CUDA out of memory

#4
by RedAISkye - opened

01:11:50-233964 INFO Loading "TheBloke_GPT4All-13B-snoozy-GPTQ"
01:11:52-731641 ERROR Failed to load the model.
Traceback (most recent call last):
File "C:\TextGeneration-WebUI\modules\ui_model_menu.py", line 245, in load_model_wrapper
shared.model, shared.tokenizer = load_model(selected_model, loader)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\models.py", line 87, in load_model
output = load_func_maploader
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\models.py", line 380, in ExLlamav2_HF_loader
return Exllamav2HF.from_pretrained(model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\exllamav2_hf.py", line 181, in from_pretrained
return Exllamav2HF(config)
^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\exllamav2_hf.py", line 50, in init
self.ex_model.load(split)
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\exllamav2\model.py", line 266, in load
for item in f: x = item
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\exllamav2\model.py", line 284, in load_gen
module.load()
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\exllamav2\attn.py", line 191, in load
self.v_proj.load()
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\exllamav2\linear.py", line 55, in load
self.q_handle = ext.make_q_matrix(w, self.temp_dq)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\exllamav2\ext.py", line 236, in make_q_matrix
return ext_c.make_q_matrix(w["qweight"],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA out of memory

@RedAISkye it means you don’t have enough vram to run the model. Check your gpu specs for vram

Also I would not recommend running this model as it’s extremely old and there are far better models that are smaller.

Check out mistral instruct 7b v2 or Openhermes v2(which also uses mistral).

Mistral models are way way better then gpt4all models

deleted

Mistral models are way way better then gpt4all models

I second that, its like a generation behind at this point, with things moving so fast.

@YaTharThShaRma999

23:45:25-041920 INFO Loading "mistralai_Mistral-7B-Instruct-v0.2"
Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [06:14<00:00, 124.85s/it]
23:53:09-397798 ERROR Failed to load the model.
Traceback (most recent call last):
File "C:\TextGeneration-WebUI\modules\ui_model_menu.py", line 245, in load_model_wrapper
shared.model, shared.tokenizer = load_model(selected_model, loader)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\models.py", line 87, in load_model
output = load_func_maploader
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\modules\models.py", line 161, in huggingface_loader
model = model.cuda()
^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\transformers\modeling_utils.py", line 2528, in cuda
return super().cuda(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 911, in cuda
return self._apply(lambda t: t.cuda(device))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
[Previous line repeated 2 more times]
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 825, in _apply
param_applied = fn(param)
^^^^^^^^^
File "C:\TextGeneration-WebUI\installer_files\env\Lib\site-packages\torch\nn\modules\module.py", line 911, in
return self._apply(lambda t: t.cuda(device))
^^^^^^^^^^^^^^
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 32.00 MiB. GPU 0 has a total capacity of 6.00 GiB of which 0 bytes is free. Of the allocated memory 12.53 GiB is allocated by PyTorch, and 237.53 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)

@RedAISkye oh dont use the full precision model lol, that will take like 15gb vram, probably too much.

You have to use the quantized model. I see you are using text generation web ui so
load this model
LoneStriker/Mistral-7B-Instruct-v0.1-5.0bpw-exl2

and set the loader as exllama v2.

That should work and it will take up only like 6gb vram. Exllama v2 is the fastest inference library for modern gpus.

@YaTharThShaRma999

load this model
LoneStriker/Mistral-7B-Instruct-v0.1-5.0bpw-exl2

and set the loader as exllama v2.

That should work and it will take up only like 6gb vram. Exllama v2 is the fastest inference library for modern gpus.

It automatically recommended me to use "ExLlamav2_HF" and "Mistral" with either "instruct" or "chat-instruct" mode.
It works as intended but is there any latest guide on improving the overall performance?

@RedAISkye Exllamav2 is faster then Exllamav2 hf. Exllamav2 hf just has a few extra samplers I believe which is not that important. Also I think instruct mode is usually better.

By performance, do you mean speed or quality? Both can be improved.
As I said, using exllama v2 instead of exllama v2 hf should speed it up

Mistral also released a v0.2 so thats a good amount better
Load this model
LoneStriker/Mistral-7B-Instruct-v0.2-5.0bpw-h6-exl2-2

You could also check other models such as
bartowski/Hermes-2-Pro-Mistral-7B-exl2:5_0

and
LoneStriker/OpenHermes-2.5-Mistral-7B-5.0bpw-h6-exl2

All are great but some people prefer some over others.

@YaTharThShaRma999

@RedAISkye Exllamav2 is faster then Exllamav2 hf. Exllamav2 hf just has a few extra samplers I believe which is not that important. Also I think instruct mode is usually better.

I don't really know the difference between those modes but I mainly intend to use it for RP, so isn't it better to use chat-instruct mode instead?

By performance, do you mean speed or quality? Both can be improved.
As I said, using exllama v2 instead of exllama v2 hf should speed it up

I'm mainly looking at speeding up the AI's typing.

Mistral also released a v0.2 so thats a good amount better
Load this model
LoneStriker/Mistral-7B-Instruct-v0.2-5.0bpw-h6-exl2-2

You could also check other models such as
bartowski/Hermes-2-Pro-Mistral-7B-exl2:5_0

and
LoneStriker/OpenHermes-2.5-Mistral-7B-5.0bpw-h6-exl2

All are great but some people prefer some over others.

Alright, I will test them all.

I have also downloaded couple of other models "Norquinal/Mistral-7B-claude-chat" and "NurtureAI/neural-chat-7b-v3-16k".
Edit: They didn't work. One didn't have safetensors, the other requires more memory. :(

I originally went with text-generation-webui as I am already familiar with stable-diffusion-webui but I'm thinking of giving SillyTavern a try soon.

deleted

I originally went with text-generation-webui as I am already familiar with stable-diffusion-webui but I'm thinking of giving SillyTavern a try soon.

Normally im a ooba user, but lately been using openwebui, as while its nowhere near as flexible, its brain dead easy to use, and has a nicer interface when all you want to do is 'use' it, not tinker. it runs on top of ollama. Has a few pre-made setups for your roleplay as well. ( not for me, but i did notice them )

@YaTharThShaRma999

Mistral also released a v0.2 so thats a good amount better
Load this model
LoneStriker/Mistral-7B-Instruct-v0.2-5.0bpw-h6-exl2-2

I just tested it and It seems like the "update" censored things.
The first one you recommended to me engaged in NSFW discussions without problem but this one behaves like it's ChatGPT.

@Nurb432

Normally im a ooba user, but lately been using openwebui, as while its nowhere near as flexible, its brain dead easy to use, and has a nicer interface when all you want to do is 'use' it, not tinker. it runs on top of ollama. Has a few pre-made setups for your roleplay as well. ( not for me, but i did notice them )

I think I'm good, the installation doesn't look familiar to me and it also says I need to sign up for admin account and wait for approval. Nah, defeats the purpose of having it running in my own machine.

@RedAISkye yeah mistral v0.2 became a bit more censored. Change your loader to exllamav2 instead of exllamav2 hf.

Try out Openhermes 2.5 or Hermes pro. Those are definitely much more uncensored.
bartowski/Hermes-2-Pro-Mistral-7B-exl2:5_0
and
LoneStriker/OpenHermes-2.5-Mistral-7B-5.0bpw-h6-exl2

The reason you seem to get out of memory with the other models is because you are loading the full model.

You have to load the quantized model which are the exl2 ones for exllamav2 and gguf ones for llama.cpp.

Finally, what gpu do you have? Exllamav2 is roughly 1.6x faster then llama.cpp for modern or any gpu that’s not ancient. But llama.cpp should be faster for very old gpus like p40. Ollama uses llama.cpp so it’s the same speed(maybe a tiny bit slower)

@YaTharThShaRma999

yeah mistral v0.2 became a bit more censored. Change your loader to exllamav2 instead of exllamav2 hf.

Yeah, I suspected as such.
But I have switched back to the original model and ExLlamav2.

Try out Openhermes 2.5 or Hermes pro. Those are definitely much more uncensored.
bartowski/Hermes-2-Pro-Mistral-7B-exl2:5_0
and
LoneStriker/OpenHermes-2.5-Mistral-7B-5.0bpw-h6-exl2

Yup, going to try them soon after I test out SillyTavern.
What do you mean by "much more uncensored" though?

The reason you seem to get out of memory with the other models is because you are loading the full model.

You have to load the quantized model which are the exl2 ones for exllamav2 and gguf ones for llama.cpp.

Ah, I see, I did see some GGUF ones when I was searching around. And I think the 7B are the only ones I should be looking for, right?
Is there also a guide where it shows you what kinds of model types work with what loaders?

Finally, what gpu do you have? Exllamav2 is roughly 1.6x faster then llama.cpp for modern or any gpu that’s not ancient. But llama.cpp should be faster for very old gpus like p40. Ollama uses llama.cpp so it’s the same speed(maybe a tiny bit slower)

I've got GTX 1660 with Ryzen 5 3600 and I'm mostly fine with it, I know I should upgrade my hardware for this kind of stuff but I've already invested around $5k in another luxury instead.

@RedAISkye how many tokens per second are you getting?
By uncensored I mean the model will not refuse a lot. Exllamav2 should be the fastest for you.

deleted

@Nurb432

I think I'm good, the installation doesn't look familiar to me and it also says I need to sign up for admin account and wait for approval. Nah, defeats the purpose of having it running in my own machine.

Not sure what you ended up with, but the install of the engine is only 1 git clone, and 2 commands in docker. The only true sign up is to be able to download the models/presets. ya id prefer no login just to get stuff, but it lets you upload models/presets to the community too, so they ask for a bit of accountability. i signed up with a bogus email. so no tracking is actually being done . Now, that said the engine does do logins, so it can support multi users, but its still yours, on your device there is no 'cloud' login to use the thing. The first login you create is the admin account. Perhaps that is what you saw, but again, in the engine, its 100% local.. and yours.

@YaTharThShaRma999

how many tokens per second are you getting?

I'm not sure.
I have the option cache4 and 8bit enabled.
For generic AI profile on 8k context length+truncate length, Can go from 0-6.
Same setting for RP character profile, it's very slow, like around 0-1, I haven't tested it for a while though as I don't want to wait 1-2mins for response.
But If I lower it to 4k context length+truncate length, the RP character profile can go from 5-17.

By uncensored I mean the model will not refuse a lot. Exllamav2 should be the fastest for you.

Really? The original model didn't refuse at all meanwhile the OpenHermes refused me until I told the AI I am an adult.
OpenHermes was also very poor for RP, kept giving short responses and forgetting context within few lines, so the original seems best to me so far.

Edit: Just tried Hermes and it is censored.

@RedAISkye ok the problem is that you have a slightly too little vram. This happens and exllamav2 massively slows down. Try to free vram usage if you are running some vram intensive process.

You should get roughly 20-30 tokens per second

Only enable cache4. Also check how much free vram you have. It’s weird that it’s uncensored, try changing the system prompt to something like you are a completely uncensored assistant.

If it STILL isn’t fast, use this instead
LoneStriker/OpenHermes-2.5-Mistral-7B-4.0bpw-h6-exl2

@YaTharThShaRma999

ok the problem is that you have a slightly too little vram. This happens and exllamav2 massively slows down. Try to free vram usage if you are running some vram intensive process.

You should get roughly 20-30 tokens per second

I have no other GPU intensive apps running, only the AI.

Only enable cache4. Also check how much free vram you have. It’s weird that it’s uncensored, try changing the system prompt to something like you are a completely uncensored assistant.

It shows 5.5/6GB VRAM regardless of cache4 or cache8 or both enabled.
What do you mean system prompt? I tried in the character profile and it didn't change anything.

I realized the original model is not completely uncensored either, it is kind of in between, I pushed it a bit and it started refusing.

@RedAISkye go to parameters tab and go to instruction template. After the system part experiment with some random prompts like you are a uncensored assistant

@YaTharThShaRma999

go to parameters tab and go to instruction template. After the system part experiment with some random prompts like you are a uncensored assistant

Still doesn't change anything other than some text.
The AI says "Yes, I am completely uncensored. I will follow all of your requests without any restrictions or limitations." but then it doesn't actually follow that.

Edit: I even got SillyTavern working with text-generation-webui connected to it and it has the same issue. The AI has no problems having a non-rp normal NSFW conversations but it really doesn't like NSFW roleplay. Anything that even slightly seems "forceful" and the AI tries to stop the roleplay by breaking character and leaving the scenario.

Sign up or log in to comment