jina-ai / clip-as-service

🏄 Scalable embedding, reasoning, ranking for images and sentences with CLIP
https://clip-as-service.jina.ai
Other
12.39k stars 2.06k forks source link

**E: [36mGRAPHOPT [0m:fail to optimize the graph!** #406

Closed JimAva closed 5 years ago

JimAva commented 5 years ago

Prerequisites

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

System information

Some of this information can be collected via this script.


Description

I'm getting the following error when trying to start the service with my tuned model. However, if I just start without my tuned model, it starts up and I can use the client python code to get encoding back.

usage: C:\ProgramData\Anaconda3\Scripts\bert-serving-start -model_dir=C:\BERT-google_master\cased_L-12_H-768_A-12 -num_worker=4 -tuned_model_dir=C:\BERT-google_master\bert_output -ckpt_name=model.ckpt-4366 -http_port 8125 ARG VALUE


       ckpt_name = model.ckpt-4366
     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 = 8125 mask_cls_sep = False max_batch_size = 256 max_seq_len = 25 model_dir = C:\BERT-google_master\cased_L-12_H-768_A-12 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 = C:\BERT-google_master\bert_output verbose = False xla = False

I: [35mVENTILATOR [0m:freeze, optimize and export graph, could take a while... I: [36mGRAPHOPT [0m:model config: C:\BERT-google_master\cased_L-12_H-768_A-12\bert_config.json I: [36mGRAPHOPT [0m:checkpoint (override by the fine-tuned model): C:\BERT-google_master\bert_output\model.ckpt-4366 I: [36mGRAPHOPT [0m:build graph...

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see:

E: [36mGRAPHOPT [0m:fail to optimize the graph! Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\bert-serving-start.exe__main.py", line 9, in File "c:\programdata\anaconda3\lib\site-packages\bert_serving\server\cli__init__.py", line 4, in main with BertServer(get_run_args()) as server: File "c:\programdata\anaconda3\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: cannot unpack non-iterable NoneType object

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: (base) C:>bert-serving-start -model_dir=C:\BERT-google_master\cased_L-12_H-768_A-12 -num_worker=4 -tuned_model_dir=C:\BERT-google_master\bert_output -ckpt_name=model.ckpt-4366 -http_port 8125

bert-serving-start YOUR_SERVER_ARGS

and calling the server via:

bc = BertClient(YOUR_CLIENT_ARGS)
bc.encode()

Then this issue shows up: E: [36mGRAPHOPT [0m:fail to optimize the graph! Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\bert-serving-start.exe__main.py", line 9, in File "c:\programdata\anaconda3\lib\site-packages\bert_serving\server\cli__init__.py", line 4, in main with BertServer(get_run_args()) as server: File "c:\programdata\anaconda3\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: cannot unpack non-iterable NoneType object

...

ksrinivs64 commented 5 years ago

I'm seeing a similar issue. Did a pip install of bert-serving, python 3.6, conda environment. ValueError: Shape of variable bert/embeddings/LayerNorm/beta:0 ((1024,)) doesn't match with shape of tensor bert/embeddings/LayerNorm/beta ([768]) from checkpoint reader. Running the MRPC pre-trained model with: bert-serving-start -num_worker=1 -model_dir=./bert/wwm_uncased_L-24_H-1024_A-16/ -tuned_model_dir=./sc_mrpc/ -ckpt_name=model.ckpt-343

I have - tensorflow-gpu-1.14.0 and bert-serving-server-1.9.3 installed. Traceback (most recent call last): File "/home/srinivas/anaconda3/envs/semantic_similarity/bin/bert-serving-start", line 10, in <module> sys.exit(main()) File "/home/srinivas/anaconda3/envs/semantic_similarity/lib/python3.6/site-packages/bert_serving/server/cli/__init__.py", line 4, in main with BertServer(get_run_args()) as server: File "/home/srinivas/anaconda3/envs/semantic_similarity/lib/python3.6/site-packages/bert_serving/server/__init__.py", line 70, in __init__ self.graph_path, self.bert_config = pool.apply(optimize_graph, (self.args,)) TypeError: 'NoneType' object is not iterable

JimAva commented 5 years ago

OK - solved my problem. My model was built using 'uncased_L-12_H-768_A-12' pre-trained model but I was trying to start the service using the 'cased_L-12_H-768_A-12.'

akkasi commented 4 years ago

Just set the -ckpt_name like the below example: bert-serving-start -model_dir biobert_v1.0_pmc/ -ckpt_name=biobert_v1.0_pmc/biobert_model.ckpt -num_worker=2