Bert-as-service: 启动时时报【GRAPHOPT:fail to optimize the graph!】

Created on 23 Oct 2019  ·  14Comments  ·  Source: hanxiao/bert-as-service

I:VENTILATOR:freeze, optimize and export graph, could take a while...
I:GRAPHOPT:model config: /d/work/chinese_L-12_H-768_A-12/bert_config.json
I:GRAPHOPT:checkpoint: /d/work/chinese_L-12_H-768_A-12/bert_model.ckpt
E:GRAPHOPT:fail to optimize the graph!
Traceback (most recent call last):
File "D:\Python\Python37\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Python\Python37\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Softwares\envNLP\Scripts\bert-serving-start.exe__main__.py", line 7, in
File "d:\softwares\envnlp\lib\site-packages\bert_serving\server\cli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "d:\softwares\envnlp\lib\site-packages\bert_serving\server__init__.py", line 70, in __init__
self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,))
TypeError: cannot unpack non-iterable NoneType object

Most helpful comment

Try giving the absolute path for the model dir

All 14 comments

I have the same issue and it seems related to path but no other mentioned solutions worked.
Now I need to read the source code and edit it myself.

@shamrockzhao
I traced the code and found error but I am not familiar with Tensorflow so I could not fix it.

469

I had the same issue. Downgraded from TF 2.0 to 1.10 and it worked. Something to do with new logging

I downgraded to 1.15 and it did not work. Also I changed source code and removed all loggings and added some breakpoints and found out the model cannot be constructed and code never stops in loggings even before I remove them.

Try giving the absolute path for the model dir

@mtedmist I tried all possible way of giving the path and it does not work on tensorflow 1.15>
I have not tried tf 1.10 yet as @TheJdxfh said. I think he is right, because other issues pointing out to tf version and the ones who achieved output, did not used updated tensorflow.

@Nikronic 1.15 works for me. Make sure you extract the model and point to the directory

I am also facing same issues, but on one machine with GPU MX130 it runs with tensorflow1.15 but only on CPU not on GPU, but with same software environment its not working another machine with GTX 960M.

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
E:GRAPHOPT:fail to optimize the graph!
Traceback (most recent call last):
File "d:\anaconda3\envs\gpu_test\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\anaconda3\envs\gpu_test\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\envs\gpu_test\Scripts\bert-serving-start.exe__main__.py", line 7, in
File "d:\anaconda3\envs\gpu_test\lib\site-packages\bert_serving\server\cli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "d:\anaconda3\envs\gpu_test\lib\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

....................................................
Im meeting same error with cuda 9.0, tf=1.10

@TheJdxfh @mtedmist

How can I downgrade my TF using anaconda on windows?

@TheJdxfh @mtedmist

How can I downgrade my TF using anaconda on windows?

First you should delete the current version:
pip uninstall tensorflow
Then you can install the specific version you want to. Ex:
pip install tensorflow==1.13.1
Then you are good to go

I am also facing same issues, but on one machine with GPU MX130 it runs with tensorflow1.15 but only on CPU not on GPU, but with same software environment its not working another machine with GTX 960M.

I:�[36mGRAPHOPT�[0m:model config: ./uncased_L-12_H-768_A-12/bert_config.json
I:�[36mGRAPHOPT�[0m:checkpoint: ./uncased_L-12_H-768_A-12/bert_model.ckpt
E:�[36mGRAPHOPT�[0m:fail to optimize the graph!
Traceback (most recent call last):
File "d:\anaconda3\envs\gpu_test\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\anaconda3\envs\gpu_test\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\Anaconda3\envs\gpu_test\Scripts\bert-serving-start.exe__main__.py", line 7, in File "d:\anaconda3\envs\gpu_test\lib\site-packages\bert_serving\server\cli__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "d:\anaconda3\envs\gpu_test\lib\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

....................................................
Im meeting same error with cuda 9.0, tf=1.10

Most probably the script cannot find path to your model.
Check whether uncased_L-12_H-768_A-12/ exists or try to provide absolute path to the model directory.

You should also uninstall tensorfflow-estimator if its version > 2
pip uninstall tensorflow
pip uninstall tensorflow-estimator
and then
pip install tensorflow=1.13.1

Just use absolute path

Just use absolute path

Thanks bro

Was this page helpful?
0 / 5 - 0 ratings