Bert-as-service: mac鍚姩bert-server鎶ラ敊TypeError: cannot unpack non-iterable NoneType object

Created on 5 Mar 2020  路  8Comments  路  Source: hanxiao/bert-as-service

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.7/site-packages/bert_serving/server/graph.py", line 42, in optimize_graph
tf = import_tf(verbose=args.verbose)
File "/usr/local/lib/python3.7/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 "/usr/local/bin/bert-serving-start", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/bert_serving/server/cli/__init__.py", line 4, in main
with BertServer(get_run_args()) as server:
File "/usr/local/lib/python3.7/site-packages/bert_serving/server/__init__.py", line 71, in __init__
self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,))
TypeError: cannot unpack non-iterable NoneType object

Most helpful comment

This error can be cause by multiple reasons:

(1) Installing the wrong version of TensorFlow;
You should install TensorFlow >= 1.10 and <=1.15 (don't install TensorFlow 2.0)

(2) When trying to start the server using the command:
bert-serving-start -model_dir cased_L-24_H-1024_A-16/ -num_worker=4

change the path to the _model_dir_ to point to the model directory in your machine.

All 8 comments

This error can be cause by multiple reasons:

(1) Installing the wrong version of TensorFlow;
You should install TensorFlow >= 1.10 and <=1.15 (don't install TensorFlow 2.0)

(2) When trying to start the server using the command:
bert-serving-start -model_dir cased_L-24_H-1024_A-16/ -num_worker=4

change the path to the _model_dir_ to point to the model directory in your machine.

I am still unable to do it. What am I doing wrong?
The path of the folder is:
image

The command I'm running is:

image

@shikhar42 looks like you're need a space between your path and num_workers.

@ghunkins thank you for your reply. But when I do that, I get the following error

image

I was getting this error earlier and when I removed spaces between the path and num_workers, it accepted num_workers as an argument but then it fails with the type error optimizing the graph.

@shikhar42 It defaults to gpu config I believe, add the -cpu flag and you should be fine. It's failing on some CUDA configuration, so the CPU should bypass that.

@ghunkins
image

Is this what you mean, or am I doing something wrong?
Thanks

anyone else facing the same issue?

@shikhar42 you need to initialize your model_dir with the absolute path not the relative path.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JulianGerhard21 picture JulianGerhard21  路  4Comments

kirdin picture kirdin  路  3Comments

k-oul picture k-oul  路  7Comments

KODGV picture KODGV  路  6Comments

applenob picture applenob  路  7Comments