Bert-as-service: TypeError: 'NoneType' object is not iterable

Created on 29 Nov 2019  ·  18Comments  ·  Source: hanxiao/bert-as-service

env
win10
python3.6
bert-serving-client/server 1.9.7
tensorflow 1.14.0
and i got this:
E:\Software\Python3.6.5\Scripts>bert-serving-start -model_dir ./uncased_L-12_H-768_A-12/ -num_worker=4
usage: E:\Software\Python3.6.5\Scriptsbert-serving-start -model_dir ./uncased_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 = ./uncased_L-12_H-768_A-12/
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:freeze, optimize and export graph, could take a while...
WARNING:tensorflow:From e:\software\python3.6.5lib\site-packagesbert_servingserver\helper.py:184: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

WARNING:tensorflow:From e:\software\python3.6.5lib\site-packagesbert_servingserver\helper.py:184: The name tf.logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead.

I:GRAPHOPT:model config: ./uncased_L-12_H-768_A-12/bert_config.json
I:GRAPHOPT:checkpoint: ./uncased_L-12_H-768_A-12/bert_model.ckpt
I:GRAPHOPT:build graph...
E:GRAPHOPT:fail to optimize the graph!
Traceback (most recent call last):
File "e:\software\python3.6.5lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "e:\software\python3.6.5lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:\Software\Python3.6.5\Scriptsbert-serving-start.exe__main__.py", line 9, in
File "e:\software\python3.6.5lib\site-packagesbert_servingservercli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "e:\software\python3.6.5lib\site-packagesbert_servingserver__init__.py", line 71, in __init__
self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,))
TypeError: 'NoneType' object is not iterable

Most helpful comment

I have the same question!Have you solved it?

I change to another env with
tensorflow 1.13.1
bert-serving-client/server 1.9.9
python3.7
and it works well😀

All 18 comments

I have the same question!Have you solved it?

Facing the same issue when I tried to start the server, here is the stacktrace - looks like issue related to tensorflow 2.0 updates. Please let us know if this will be addressed soon.

I:VENTILATOR:[__i:__i: 67]:freeze, optimize and export graph, could take a while...
E:GRAPHOPT:[gra:opt:151]:fail to optimize the graph!
Traceback (most recent call last):
File "skc/environments/.virtualenvs/bert/lib/python3.6/site-packages/bert_serving/server/graph.py", line 41, in optimize_graph
tf = import_tf(verbose=args.verbose)
File "/environments/.virtualenvs/bert/lib/python3.6/site-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 "/environments/.virtualenvs/bert/bin/bert-serving-start", line 8, in
sys.exit(main())
File "/environments/.virtualenvs/bert/lib/python3.6/site-packages/bert_serving/server/cli/__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "/home/imagen/skc/environments/.virtualenvs/bert/lib/python3.6/site-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
$ bert-serving-start -model_dir /bert/bert-models/cased_L-12_H-768_A-12/ -num_worker=1
/home/imagen/skc/environments/.virtualenvs/bert/lib/python3.6/site-packages/bert_serving/server/helper.py:176: UserWarning: Tensorflow 2.0.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__)

sorry - downgrading to tensorflow 1.x worked, it was due to 2.0 updates. I tried to upgrade the bert_serving scripts using 2.0 tools, but I wasn't successful as there were some errors.

I have the same question!Have you solved it?

I change to another env with
tensorflow 1.13.1
bert-serving-client/server 1.9.9
python3.7
and it works well😀

sorry - downgrading to tensorflow 1.x worked, it was due to 2.0 updates. I tried to upgrade the bert_serving scripts using 2.0 tools, but I wasn't successful as there were some errors.

but with my env with tensorflow 1.14.0 it seems doesn't work....

downgrading to tensorflow version 1.15 seems to work for me

check the path of the downloaded model.

I have the same question!Have you solved it?

I change to another env with
tensorflow 1.13.1
bert-serving-client/server 1.9.9
python3.7
and it works well😀

thank you so much , finally it work for me !

I meet that issue to..but I don't want to downgrading,Is there have any other settlement work for 2.0

I am still facing the above issue have tried couple of solutions.
Version - tensorflow-cpu = 1.13.1
Bert_serving_client = 1.9.9
Bert_serving_server = 1.9.9

I am running the below command after locating at model_dir
command bert-serving-start -model_dir uncased_L-2_H-128_A-2\ -cpu
files present in model_dir :bert_config.json,bert_model.ckpt.data-00000-of-00001,bert_model.ckpt.index,vocab.txt
have tried with providing absolute path till model directory too
system config - 12 gb ram.
let me know how could I resolve this.Thanks in advance

I am getting the same problem in windows, although I tried all the methods.
"TypeError: 'NoneType' object is not iterable".
Please somebody help me.

你们模型目录写错啦

你们模型目录写错啦
那应该怎么写呢,没有发现哪里写错了

你们模型目录写错啦
那应该怎么写呢,没有发现哪里写错了

你试试绝对路径

你们模型目录写错啦
那应该怎么写呢,没有发现哪里写错了

你试试绝对路径

还是不行的,我的绝对路径还是不行,不过还是谢谢你啦

加速 入关

你们模型目录写错啦
那应该怎么写呢,没有发现哪里写错了

你试试绝对路径

还是不行的,我的绝对路径还是不行,不过还是谢谢你啦

有可能是tensorflow版本过高,api不兼容,只支持1.x.x版本的。报错信息跟进去,可以看到源码,大于1的版本会报一个未测试验证的警告。

Was this page helpful?
0 / 5 - 0 ratings