开发者社区 > ModelScope模型即服务 > 自然语言处理 > 正文

pipline中不能使用device_map参数

pipeline_se = pipeline(Tasks.sentence_embedding, model=model_id, device_map='auto')

报错如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/pipelines/base.py", line 218, in __call__
    output = self._process_single(input, *args, **kwargs)
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/pipelines/base.py", line 246, in _process_single
    out = self.preprocess(input, **preprocess_params)
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/pipelines/base.py", line 387, in preprocess
    return self.preprocessor(inputs, **preprocess_params)
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/preprocessors/nlp/sentence_embedding_preprocessor.py", line 84, in __call__
    query_inputs = self.nlp_tokenizer(
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/preprocessors/nlp/transformers_tokenizer.py", line 108, in __call__
    return self.tokenizer(text, text_pair, **tokenize_kwargs)
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2561, in __call__
    encodings = self._call_one(text=text, text_pair=text_pair, **all_kwargs)
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2647, in _call_one
    return self.batch_encode_plus(
  File "/root/miniconda3/envs/modelscope/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2838, in batch_encode_plus
    return self._batch_encode_plus(
TypeError: _batch_encode_plus() got an unexpected keyword argument 'device_map'

展开
收起
1439304173723468 2023-08-09 17:32:18 567 0
1 条回答
写回答
取消 提交回答
  • 您好,在 PyTorch 1.6 中,device_map 参数已被弃用。如果需要在 Pipeline 中使用多 GPU,可以使用 nn.DataParallel 或 dist.DistributedDataParallel。

    2023-09-22 16:36:14
    赞同 展开评论 打赏

包含命名实体识别、文本分类、分词、关系抽取、问答、推理、文本摘要、情感分析、机器翻译等多个领域

热门讨论

热门文章

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载