LlamaCppEmbeddings - fails if all available GPU layers are used.
Labels: name: area: embeddings, name: auto:bug

### System Info

Langchain 0.0.326
Windows
Python 3.11.5
Nvidia P6-16Q GPU

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Loading up all available GPU layers appears to cause LlamaCppEmbeddings to fail?

- Edit: this was my original submission because I was using -1 for the n_gpu_layers but I did further testing and noted that it was only if you used 34 or 35 - for 33 it works, but not 34 or 35.

For example this fails:

`llama = LlamaCppEmbeddings(model_path=r"mistral-7b-instruct-v0.1.Q5_K_M.gguf", n_ctx=512, n_gpu_layers=34)`

```
llm_load_tensors: ggml ctx size =    0.09 MB
llm_load_tensors: using CUDA for GPU acceleration
llm_load_tensors: mem required  =   86.05 MB (+  128.00 MB per state)
llm_load_tensors: offloading 32 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloading v cache to GPU
llm_load_tensors: offloaded 34/35 layers to GPU
llm_load_tensors: VRAM used: 4840 MB
```

With this error message:

```
Traceback (most recent call last):
  File "c:\Users\x\Desktop\Embedding\EmbeddingScript.py", line 11, in <module>
    query_result = llama.embed_query("Hello World")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain\embeddings\llamacpp.py", line 125, in embed_query
    embedding = self.client.embed(text)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\llama_cpp\llama.py", line 860, in embed
    return list(map(float, self.create_embedding(input)["data"][0]["embedding"]))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\llama_cpp\llama.py", line 824, in create_embedding
    self.eval(tokens)
  File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\llama_cpp\llama.py", line 491, in eval
    return_code = llama_cpp.llama_eval(
                  ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\llama_cpp\llama_cpp.py", line 808, in llama_eval
    return _lib.llama_eval(ctx, tokens, n_tokens, n_past, n_threads)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000000
```

However, this does not fail:

`llama = LlamaCppEmbeddings(model_path=r"mistral-7b-instruct-v0.1.Q5_K_M.gguf", n_ctx=512, n_gpu_layers=33)`

```
lm_load_tensors: ggml ctx size =    0.09 MB
llm_load_tensors: using CUDA for GPU acceleration
llm_load_tensors: mem required  =   86.05 MB (+  128.00 MB per state)
llm_load_tensors: offloading 32 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloaded 33/35 layers to GPU
llm_load_tensors: VRAM used: 4808 MB
```

It may not be a langchain problem, I am not knowledgeable enough to know - but not sure why you can't load up all the available layers of the GPU?

### Expected behavior

I would have thought that using all available layers of the GPU would not cause it to fail.