nvml error when model.generate

#30
by bobo8 - opened

dear,

I am getting below error when running test:

Traceback (most recent call last):
File "", line 1, in
File "/vllm/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/vllm/lib/python3.10/site-packages/transformers/generation/utils.py", line 1544, in generate
return self.greedy_search(
File "/vllm/lib/python3.10/site-packages/transformers/generation/utils.py", line 2404, in greedy_search
outputs = self(
File "/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/vllm/lib/python3.10/site-packages/transformers/models/gemma/modeling_gemma.py", line 1067, in forward
outputs = self.model(
File "/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/vllm/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/vllm/lib/python3.10/site-packages/transformers/models/gemma/modeling_gemma.py", line 876, in forward
causal_mask = self._update_causal_mask(attention_mask, inputs_embeds)
File "/vllm/lib/python3.10/site-packages/transformers/models/gemma/modeling_gemma.py", line 960, in update_causal_mask
self.causal_mask[None, None, :, :].repeat(batch_size, 1, 1, 1).to(dtype) * torch.finfo(dtype).min
RuntimeError: NVML_SUCCESS == DriverAPI::get()->nvmlDeviceGetHandleByPciBusId_v2
( pci_id, &nvml_device) INTERNAL ASSERT FAILED at "../c10/cuda/CUDACachingAllocator.cpp":1139, please report a bug to PyTorch.

below is the test command:

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("/root/host/pytorch/llm/gemma-2b")
model = AutoModelForCausalLM.from_pretrained("/root/host/pytorch/llm/gemma-2b", device_map="auto")

input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))

and the environments is:

torch.version
'2.1.2+cu118'

transformers 4.38.1

what could be the issue? thanks.

Hi !
Hmm do you face the same issue with other models? Might be a hardware issue but not sure. If you face the same issue with other models I think that you should submit an issue to pytorch
Alternatively, can you try:

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("/root/host/pytorch/llm/gemma-2b")
model = AutoModelForCausalLM.from_pretrained("/root/host/pytorch/llm/gemma-2b").to("cuda")

input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))

thanks, after reinstall the torch with cuda12.1, issue disappeared.

Perfect, thanks @bobo8 !

osanseviero changed discussion status to closed

Sign up or log in to comment