browsermt / bergamot-translator

Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
http://browser.mt
Mozilla Public License 2.0
340 stars 38 forks source link

Make default throwExceptionOnAbort #332

Open jerinphilip opened 2 years ago

jerinphilip commented 2 years ago

Marian is configured to exit on abort. translateLocally switches to throwOnAbort.... This is already mentioned in https://github.com/browsermt/bergamot-translator/issues/221, but this issue is just meant to track this specifically.

https://github.com/XapaJIaMnu/translateLocally/blob/6f40bceedb4909dfead81441cfb606582c43dcaf/src/main.cpp#L13

// Set marian to throw exceptions instead of std::abort()
marian::setThrowExceptionOnAbort(true);

From experience, the python tooling should be able to gracefully do exceptions. I instead get random crashes on Colab. I should be able to get meaningful errors instead.

(env) [jerin@eltbk hf-issue-15109]$ ls -l
total 1777300
-rw-rw---- 1 jerin users       423 Dec  3 22:11 config-bt.mk
-rw-rw-r-- 1 jerin users       305 Dec  8 09:14 decoder.yml
-rw-r----- 1 jerin users     18652 Dec  8 09:14 LICENSE
-rw-r--r-- 1 jerin users 874629520 Dec 10 10:24 opusTCv20210807+bt-2021-12-08.zip
-rw-rw-r-- 1 jerin users 942581890 Dec  7 03:48 opusTCv20210807+bt.spm32k-spm32k.transformer-big.model1.npz.best-perplexity.npz
-rw-rw-r-- 1 jerin users      2121 Dec  8 09:14 opusTCv20210807+bt.spm32k-spm32k.transformer-big.model1.npz.best-perplexity.yml
-rw-rw-r-- 1 jerin users     66772 Dec  7 20:04 opusTCv20210807+bt.spm32k-spm32k.transformer-big.train1.log
-rw-rw-r-- 1 jerin users      3926 Dec  7 20:04 opusTCv20210807+bt.spm32k-spm32k.transformer-big.valid1.log
-rw-rw---- 1 jerin users    993770 Nov  3 22:11 opusTCv20210807+bt.spm32k-spm32k.vocab.yml
-rwxrwx--- 1 jerin users        80 Dec  8 09:14 postprocess.sh
-rwxrwx--x 1 jerin users      1413 Dec  8 09:14 preprocess.sh
-rw-rw---- 1 jerin users      1610 Dec  8 09:14 README.md
-rw-rw---- 1 jerin users    831865 Dec  8 09:14 source.spm
-rw-rw-r-- 1 jerin users         0 Dec  8 09:14 source.tcmodel
-rw-rw---- 1 jerin users    789795 Dec  8 09:14 target.spm
(env) [jerin@eltbk hf-issue-15109]$ vim run.py
(env) [jerin@eltbk hf-issue-15109]$ python3 run.py decoder.yml 
[2022-02-05 13:03:59] Unknown log level 'all' for logger 'general'
[2022-02-05 13:03:59] [valid] Unknown log level 'all' for logger 'valid'
[2022-02-05 13:03:59] Error: The file of binary model should end with .bin
[2022-02-05 13:03:59] Error: Aborted from marian::bergamot::AlignedMemory marian::bergamot::getModelMemoryFromConfig(marian::Ptr<marian::Options>) in /home/jerin/code/bergamot-translator/src/translator/byte_array_util.cpp:97

[CALL STACK]
[0x7f7be002f67b]    marian::bergamot::  getModelMemoryFromConfig  (std::shared_ptr<marian::Options>) + 0xa49
[0x7f7be00319b3]    marian::bergamot::  getMemoryBundleFromConfig  (std::shared_ptr<marian::Options>) + 0x52
[0x7f7bdff915c1]                                                       + 0x94f5c1
[0x7f7bdffa174b]                                                       + 0x95f74b
[0x7f7bdff916f8]                                                       + 0x94f6f8
[0x7f7bdff918b7]                                                       + 0x94f8b7
[0x7f7bdffbdd49]                                                       + 0x97bd49
[0x7f7be000594b]                                                       + 0x9c394b
[0x7f7bdffef269]                                                       + 0x9ad269
[0x7f7bdffd8845]                                                       + 0x996845
[0x7f7bdffd8a68]                                                       + 0x996a68
[0x7f7bdff7a641]                                                       + 0x938641
[0x7f7be370b2d2]                                                       + 0x1502d2
[0x7f7be37057cb]    _PyObject_MakeTpCall                               + 0x2ab
[0x7f7be371723b]                                                       + 0x15c23b
[0x7f7be37004f1]    _PyEval_EvalFrameDefault                           + 0x50d1
[0x7f7be36fa392]                                                       + 0x13f392
[0x7f7be37b2c14]    PyEval_EvalCode                                    + 0x94
[0x7f7be37c3b54]                                                       + 0x208b54
[0x7f7be37bf55b]                                                       + 0x20455b
[0x7f7be3658fca]                                                       + 0x9dfca
[0x7f7be3658c4a]    _PyRun_SimpleFileObject                            + 0x399
[0x7f7be36595df]    _PyRun_AnyFileObject                               + 0x89
[0x7f7be37d030b]    Py_RunMain                                         + 0x3eb
[0x7f7be37a369d]    Py_BytesMain                                       + 0x3d
[0x7f7be3416b25]    __libc_start_main                                  + 0xd5
[0x56294a45904e]    _start                                             + 0x2e

Aborted (core dumped)