Bert-as-service: TypeError: 'NoneType' object is not iterable -- cannot start the server via command window

Created on 10 Jun 2020  路  3Comments  路  Source: hanxiao/bert-as-service

Prerequisites

Please fill in by replacing [ ] with [x].

System information

Some of this information can be collected via this script.

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): win10
  • TensorFlow installed from (source or binary): I typed this in command window to install: pip3 install tensorflow-gpu==1.15
  • TensorFlow version: 1.15
  • Python version: 3.5
  • bert-as-service version: the latest version;
    I typed this in command window to install: pip3 install -U bert-serving-server bert-serving-client
  • GPU model and memory:
  • CPU model and memory:

Description

Please replace YOUR_SERVER_ARGS and YOUR_CLIENT_ARGS accordingly. You can also write your own description for reproducing the issue.

I'm using this command to start the server:
bert-serving-start -model_dir /BERT/uncased_L-24_H-1024_A-16 -num_worker=1

bert-serving-start YOUR_SERVER_ARGS

2020-06-10 11:03:25.838138: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
usage: C:UsersFanyi MoAppDataLocalProgramsPythonPython35Scriptsbert-serving-start -model_dir /BERT/uncased_L-24_H-1024_A-16 -num_worker=1
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 = /BERT/uncased_L-24_H-1024_A-16
no_position_embeddings = False
no_special_token = False
num_worker = 1
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

Then this issue shows up:
I:VENTILATOR:freeze, optimize and export graph, could take a while...
2020-06-10 11:03:30.497862: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
WARNING:tensorflow:From c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingserverhelper.py:186: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

WARNING:tensorflow:From c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingserverhelper.py:186: The name tf.logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead.

I:GRAPHOPT:model config: /BERT/uncased_L-24_H-1024_A-16bert_config.json
I:GRAPHOPT:checkpoint: /BERT/uncased_L-24_H-1024_A-16bert_model.ckpt
E:GRAPHOPT:fail to optimize the graph!
Traceback (most recent call last):
File "c:usersfanyi moappdatalocalprogramspythonpython35librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:usersfanyi moappdatalocalprogramspythonpython35librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:UsersFanyi MoAppDataLocalProgramsPythonPython35Scriptsbert-serving-start.exe__main__.py", line 7, in
File "c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingservercli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "c:usersfanyi moappdatalocalprogramspythonpython35libsite-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 met the same question, how to solve it

All 3 comments

i met the same question, how to solve it

I have the same problem and have tried numerous different model paths to no success

Prerequisites

Please fill in by replacing [ ] with [x].

System information

Some of this information can be collected via this script.

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): win10
  • TensorFlow installed from (source or binary): I typed this in command window to install: pip3 install tensorflow-gpu==1.15
  • TensorFlow version: 1.15
  • Python version: 3.5
  • bert-as-service version: the latest version;
    I typed this in command window to install: pip3 install -U bert-serving-server bert-serving-client
  • GPU model and memory:
  • CPU model and memory:

Description

Please replace YOUR_SERVER_ARGS and YOUR_CLIENT_ARGS accordingly. You can also write your own description for reproducing the issue.

I'm using this command to start the server:
bert-serving-start -model_dir /BERT/uncased_L-24_H-1024_A-16 -num_worker=1

bert-serving-start YOUR_SERVER_ARGS

2020-06-10 11:03:25.838138: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
usage: C:UsersFanyi MoAppDataLocalProgramsPythonPython35Scriptsbert-serving-start -model_dir /BERT/uncased_L-24_H-1024_A-16 -num_worker=1
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 = /BERT/uncased_L-24_H-1024_A-16
no_position_embeddings = False
no_special_token = False
num_worker = 1
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

Then this issue shows up:
I:锟絒35mVENTILATOR锟絒0m:freeze, optimize and export graph, could take a while...
2020-06-10 11:03:30.497862: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
WARNING:tensorflow:From c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingserverhelper.py:186: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

WARNING:tensorflow:From c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingserverhelper.py:186: The name tf.logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead.

I:锟絒36mGRAPHOPT锟絒0m:model config: /BERT/uncased_L-24_H-1024_A-16bert_config.json
I:锟絒36mGRAPHOPT锟絒0m:checkpoint: /BERT/uncased_L-24_H-1024_A-16bert_model.ckpt
E:锟絒36mGRAPHOPT锟絒0m:fail to optimize the graph!
Traceback (most recent call last):
File "c:usersfanyi moappdatalocalprogramspythonpython35librunpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:usersfanyi moappdatalocalprogramspythonpython35librunpy.py", line 85, in _run_code exec(code, run_globals) File "C:UsersFanyi MoAppDataLocalProgramsPythonPython35Scriptsbert-serving-start.exe__main__.py", line 7, in File "c:usersfanyi moappdatalocalprogramspythonpython35libsite-packagesbert_servingservercli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "c:usersfanyi moappdatalocalprogramspythonpython35libsite-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
...

perhaps you could check whether your model_dir path is correct.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

un-lock-me picture un-lock-me  路  3Comments

zhant09 picture zhant09  路  3Comments

KODGV picture KODGV  路  6Comments

astariul picture astariul  路  7Comments

kirdin picture kirdin  路  3Comments