Cannot copy out of meta tensor; no data!
First in order to avoid unknown mobilenetv5_300m_enc errors:
!pip uninstall -y timm
!pip install timm --upgrade
Then run the inference example of the model card and got: NotImplementedError: Cannot copy out of meta tensor; no data!
Full log:
The following generation flags are not valid and may be ignored: ['top_p', 'top_k']. Set TRANSFORMERS_VERBOSITY=info
for more details.
NotImplementedError Traceback (most recent call last)
/tmp/ipython-input-1-875231982.py in <cell line: 0>()
35
36 with torch.inference_mode():
---> 37 generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
38 generation = generation[0][input_len:]
39
21 frames
/usr/local/lib/python3.11/dist-packages/transformers/models/gemma3n/modeling_gemma3n.py in scale_corrected_output(self, corrected)
1138 def scale_corrected_output(self, corrected: torch.Tensor) -> torch.Tensor:
1139 """Scales the provided 3D tensor of shape [batch_size, num_tokens, hidden_size]."""
-> 1140 return (corrected.type_as(self.correct_output_scale) * self.correct_output_scale).type_as(corrected)
1141
1142
NotImplementedError: Cannot copy out of meta tensor; no data!
Hi @Amit5674 ,
RuntimeError: Unknown model (mobilenetv5_300m_enc)
is an error from timm
it means they are not up to date. Gemma 3n requires at least timm v1.0.16.
Please upgrade avoid the above issue, and also please upgrade the transformer
to the latest the timm
to latest version or at least to v1.0.16 to version to work with Gemma 3n models. I have successfully able to load the model after upgrading the timm to v1.0.16
.
Please find the following gist file where I have successfully able to get the output from the model.
Thanks.