ttrouill / complex

Source code for experiments in the papers "Complex Embeddings for Simple Link Prediction" (ICML 2016) and "Knowledge Graph Completion via Complex Tensor Factorization" (JMLR 2017).
Other
319 stars 83 forks source link

theano.function(self.get_pred_symb_vars(), self.pred_func) #16

Closed huguyuehuhu closed 5 years ago

huguyuehuhu commented 5 years ago

Hi, thanks for sharing this repo. I am new to Theano. When I run the command python fb15k_run.py in your Readme, I got an error. Can you provide me any advice to solve it ? Thanks!

(env_complex) gyhu@mic119:/DATA/119/gyhu/code/complex$ python fb15k_run.py WARNING (theano.configdefaults): install mkl withconda install mkl-service`: No module named 'mkl' WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions. 2019-09-10 16:23:59,712 (EFE) [INFO] Nb entities: 14951 2019-09-10 16:23:59,713 (EFE) [INFO] Nb relations: 1345 2019-09-10 16:23:59,713 (EFE) [INFO] Nb obs triples: 483142 2019-09-10 16:24:07,993 (EFE) [INFO] Learning rate: 0.5 2019-09-10 16:24:07,994 (EFE) [INFO] Max iter: 1000 2019-09-10 16:24:07,994 (EFE) [INFO] Generated negatives ratio: 10 2019-09-10 16:24:07,994 (EFE) [INFO] Batch size: 4831 2019-09-10 16:24:07,994 (EFE) [INFO] Starting grid search on: Complex_Logistic_Model

You can find the C code in this temporary file: /tmp/theano_compilation_error_8ipm74 Traceback (most recent call last): File "fb15k_run.py", line 39, in fb15kexp.grid_search_on_all_models(all_params, embedding_size_grid = [emb_size], lmbda_grid = [lmbda], nb_runs = 1) File "/DATA/119/gyhu/code/complex/efe/experiment.py", line 73, in grid_search_on_all_models self.run_model(model_s,cur_params) File "/DATA/119/gyhu/code/complex/efe/experiment.py", line 94, in run_model model.fit(self.train, self.valid, Parameters(**vars(params)), self.n_entities, self.n_relations, self. n_entities, self.scorer) File "/DATA/119/gyhu/code/complex/efe/models.py", line 152, in fit self.setup_params_for_train(train_triples, valid_triples, hparams) File "/DATA/119/gyhu/code/complex/efe/models.py", line 132, in setup_params_for_train self.pred_func_compiled = theano.function(self.get_pred_symb_vars(), self.pred_func) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function .py", line 317, in function output_keys=output_keys) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/pfunc.py ", line 486, in pfunc output_keys=output_keys) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function _module.py", line 1841, in orig_function fn = m.create(defaults) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function _module.py", line 1715, in create input_storage=input_storage_lists, storage_map=storage_map) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/link.py", li ne 699, in make_thunk storage_map=storage_map)[:3] File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/vm.py", line 1091, in make_all impl=impl)) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/op.py", line 955, in make_thunk no_recycling) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/op.py", line 858, in make_c_thunk output_storage=node_output_storage) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1217, in make_thunk keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1157, in compile__ keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1624, in cthunk_factory key=key, lnk=self, keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cmodule.py", line 1189, in module_from_key module = lnk.compile_cmodule(location) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1527, in compile_cmodule preargs=preargs) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2396, in compile_str (status, compile_stderr.replace('\n', '. '))) Exception: ('The following error happened while compiling the node', AdvancedSubtensor1(e1, tubes), '\n', "Compilation failed (return status=1): /tmp/ccpoOASs.s: Assembler messages:. /tmp/ccpoOASs.s:1675: Error: no such instruction: vinserti128 $0x1,%xmm0,%ymm1,%ymm0'. /tmp/ccpoOASs.s:1680: Error: no such instructio n:vextracti128 $0x1,%ymm0,16(%r12)'. ", '[AdvancedSubtensor1(e1, tubes)]')

`

ttrouill commented 5 years ago

Looks like your error output is telling you to install mkl with conda install mkl-service ;)

huguyuehuhu commented 5 years ago

Thanks for the reply, but I when fixed the above Warnings by conda install mkl-service, and conda install numpy scipy mkl the following the tips in here and here. The error is still here. Besides. which OS you used, Centos , Ubuntu or Other OS ?

` (env_complex) gyhu@mic119:/DATA/119/gyhu/code/complex$ python fb15k_run.py 2019-09-10 19:42:56,341 (EFE) [INFO] Nb entities: 14951 2019-09-10 19:42:56,342 (EFE) [INFO] Nb relations: 1345 2019-09-10 19:42:56,342 (EFE) [INFO] Nb obs triples: 483142 2019-09-10 19:43:05,586 (EFE) [INFO] Learning rate: 0.5 2019-09-10 19:43:05,587 (EFE) [INFO] Max iter: 1000 2019-09-10 19:43:05,587 (EFE) [INFO] Generated negatives ratio: 10 2019-09-10 19:43:05,587 (EFE) [INFO] Batch size: 4831 2019-09-10 19:43:05,587 (EFE) [INFO] Starting grid search on: Complex_Logistic_Model

You can find the C code in this temporary file: /tmp/theano_compilation_error_x5vcf38i Traceback (most recent call last): File "fb15k_run.py", line 39, in fb15kexp.grid_search_on_all_models(all_params, embedding_size_grid = [emb_size], lmbda_grid = [lmbda], nb_runs = 1) File "/DATA/119/gyhu/code/complex/efe/experiment.py", line 73, in grid_search_on_all_models self.run_model(model_s,cur_params) File "/DATA/119/gyhu/code/complex/efe/experiment.py", line 94, in run_model model.fit(self.train, self.valid, Parameters(**vars(params)), self.n_entities, self.n_relations, self.n_entities, self.scorer) File "/DATA/119/gyhu/code/complex/efe/models.py", line 152, in fit self.setup_params_for_train(train_triples, valid_triples, hparams) File "/DATA/119/gyhu/code/complex/efe/models.py", line 132, in setup_params_for_train self.pred_func_compiled = theano.function(self.get_pred_symb_vars(), self.pred_func) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function.py", line 317, in function output_keys=output_keys) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/pfunc.py", line 486, in pfunc output_keys=output_keys) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function_module.py", line 1841, in orig_function fn = m.create(defaults) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/compile/function_module.py", line 1715, in create input_storage=input_storage_lists, storage_map=storage_map) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/link.py", line 699, in make_thunk storage_map=storage_map)[:3] File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/vm.py", line 1091, in make_all impl=impl)) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/op.py", line 955, in make_thunk no_recycling) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/op.py", line 858, in make_c_thunk output_storage=node_output_storage) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1217, in make_thunk keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1157, in compile keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1624, in cthunk_factory key=key, lnk=self, keep_lock=keep_lock) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cmodule.py", line 1189, in module_from_key module = lnk.compile_cmodule(location) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cc.py", line 1527, in compile_cmodule preargs=preargs) File "/DATA/119/gyhu/soft/Anaconda3/envs/env_complex/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2396, in compile_str (status, compile_stderr.replace('\n', '. '))) Exception: ('The following error happened while compiling the node', AdvancedSubtensor1(e1, tubes), '\n', "Compilation failed (return status=1): /tmp/ccikfP39.s: Assembler messages:. /tmp/ccikfP39.s:1675: Error: no such instruction: vinserti128 $0x1,%xmm0,%ymm1,%ymm0'. /tmp/ccikfP39.s:1680: Error: no such instruction:vextracti128 $0x1,%ymm0,16(%r12)'. ", '[AdvancedSubtensor1(e1, tubes)]') `

ttrouill commented 5 years ago

I don't think this is OS related, have a look at this, it seems similar to your problem: https://github.com/Theano/Theano/issues/5604 https://github.com/Theano/Theano/issues/3780

huguyuehuhu commented 5 years ago

Thanks, I have tried them, but there is still the same error, I will try some other ways later, thanks.

ttrouill commented 5 years ago

vextracti128 and vinserti128 are instructions from the AVX2 set, that started with Haswell generation CPUs (2013), the easiest way would be to run on a more recent machine if possible.

Good luck and come back tell us if you find a solution :)

huguyuehuhu commented 5 years ago
  1. As this page points out that it is a bug of GCC 4.8.0 (similar, my GCC is 4.8.3), and it gives out two ways to solve this problem. Way1: Force no-avx2 with gcc -mno-avx2. the vextracti128 is an avx2 feature so the compiler won't use this optimization.
    Way2: Upgrade the gcc to 4.8.5

  2. For way2, it is troublesome for me because that I work on a big computing cluster with many nodes. For way1, I actually don't know how to add it. Therefore, I just list the solutions here in case that somebody else meet the same problem.

  3. Following your suggestion, I just shift to a new machine with higher GCC version, it works around, So, I think the Way2 maybe works but I won't bother to try.

Finally, thanks for your kind help again. You can close this issue if you like.

ttrouill commented 5 years ago

Maybe you can try to pass the -mno-avx2 flag by setting theano.config.gcc.cxxflags at the beginning of the python script? ( http://deeplearning.net/software/theano/library/config.html#config-attributes )

huguyuehuhu commented 5 years ago
  1. I have tried theano.config.gcc.cxxflags="-march=core2" OR theano.config.gcc.cxxflags="-mno-avx2" in my python script, both of them didn't work.
  2. Following, this one that run script by setting THEANO_FLAGS, i.e, THEANO_FLAGS='gcc.cxxflags=-march=core2' python my_model.py, it works.
  3. As the guideline in Theano suggested, setting THEANO_FLAGS, theano.config., or .theanorc file are equivalent. I have not understand why theano.config.gcc.cxxflags="-march=core2" could not work. Anyway, I can temporarily use THEANO_FLAGS='gcc.cxxflags=-march=core2' python my_model.py to run the repo .
ttrouill commented 5 years ago

Great, good news=)