demo生成时获取deviceid 失败,降低transformers库的版本后解决
Opened this issue · 0 comments
vhiccup commented
按照demo 进行fastgpt 按照和distilgpt2 model下载和onnx 转换。在transformers(版本4.28.1)的代码中报错first_tuple = next(gen) 失败,错误信息,StopIteration
`def get_parameter_device(parameter: Union[nn.Module, GenerationMixin, "ModuleUtilsMixin"]):
try:
return next(parameter.parameters()).device
except StopIteration:
# For nn.DataParallel compatibility in PyTorch 1.5
def find_tensor_attributes(module: nn.Module) -> List[Tuple[str, Tensor]]:
tuples = [(k, v) for k, v in module.__dict__.items() if torch.is_tensor(v)]
return tuples
gen = parameter._named_members(get_members_fn=find_tensor_attributes)
**first_tuple = next(gen)**
return first_tuple[1].device`
降低transformer的版本为fastgpt依赖中的 4.19后问题消失,可以预测。