bert-as-service (bert-serving-start) 对于多语言 BERT 给出 "TypeError: 'NoneType' object is not iterable" 错误,

frebpwbc  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(50)
  • x-已将此问题发布到bert-serving仓库,同时表示歉意,因为我不确定哪个是罪魁祸首。*

我正在使用以下命令启动服务器:
bert-serving-start -model_dir ./multi_cased_L-12_H-768_A-12/ -num_worker 4
然后出现了这个错误,我不知道发生了什么,错误信息太模糊了。顺便说一下,我能够运行Important:我正在使用uncased_L-12_H-768_A-12运行BERT服务,它运行得很好。所以似乎存在一些兼容性问题?

me@devbox:~/BERT_Multi$ bert-serving-start -model_dir ./multi_cased_L-12_H-768_A-12/ -num_worker 4
/usr/local/lib/python3.6/dist-packages/bert_serving/server/helper.py:176: UserWarning: Tensorflow 2.2.0 is not tested! It may or may not work. Feel free to submit an issue at https://github.com/hanxiao/bert-as-service/issues/
  'Feel free to submit an issue at https://github.com/hanxiao/bert-as-service/issues/' % tf.__version__)
usage: /usr/local/bin/bert-serving-start -model_dir ./multi_cased_L-12_H-768_A-12/ -num_worker 4
                 ARG   VALUE
__________________________________________________
           ckpt_name = bert_model.ckpt
         config_name = bert_config.json
                cors = *
                 cpu = False
          device_map = []
       do_lower_case = True
  fixed_embed_length = False
                fp16 = False
 gpu_memory_fraction = 0.5
       graph_tmp_dir = None
    http_max_connect = 10
           http_port = None
        mask_cls_sep = False
      max_batch_size = 256
         max_seq_len = 25
           model_dir = ./multi_cased_L-12_H-768_A-12/
no_position_embeddings = False
    no_special_token = False
          num_worker = 4
       pooling_layer = [-2]
    pooling_strategy = REDUCE_MEAN
                port = 5555
            port_out = 5556
       prefetch_size = 10
 priority_batch_size = 16
show_tokens_to_client = False
     tuned_model_dir = None
             verbose = False
                 xla = False

I:VENTILATOR:[__i:__i: 67]:freeze, optimize and export graph, could take a while...
E:GRAPHOPT:[gra:opt:154]:fail to optimize the graph!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/bert_serving/server/graph.py", line 42, in optimize_graph
    tf = import_tf(verbose=args.verbose)
  File "/usr/local/lib/python3.6/dist-packages/bert_serving/server/helper.py", line 186, in import_tf
    tf.logging.set_verbosity(tf.logging.DEBUG if verbose else tf.logging.ERROR)
AttributeError: module 'tensorflow' has no attribute 'logging'
Traceback (most recent call last):
  File "/usr/local/bin/bert-serving-start", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/bert_serving/server/cli/__init__.py", line 4, in main
    with BertServer(get_run_args()) as server:
  File "/usr/local/lib/python3.6/dist-packages/bert_serving/server/__init__.py", line 71, in __init__
    self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,))
TypeError: 'NoneType' object is not iterable
bttbmeg0

bttbmeg01#

我遇到了同样的问题。
我正在使用tensorflow 2.4.0。也许你也遇到了同样的问题。
这是因为那里不再存在日志记录。这里有一个解释:
https://stackoverflow.com/questions/55318626/module-tensorflow-has-no-attribute-logging
也许你应该考虑降级tensorflow版本。

相关问题