Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLEU calculation occurs only on the CPU #12

Open
LynxPDA opened this issue Jan 10, 2024 · 2 comments
Open

BLEU calculation occurs only on the CPU #12

LynxPDA opened this issue Jan 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@LynxPDA
Copy link

LynxPDA commented Jan 10, 2024

BLEU calculation occurs only on the CPU, perhaps this is somehow related to the function below

eval.py#L56C44-L56C44

def translator():
    device = "cuda" if ctranslate2.get_cuda_device_count() > 0 else "cpu"
    model = ctranslate2.Translator(ct2_model_dir, device="cpu", compute_type="default")
    if os.path.isfile(sp_model):
        tokenizer = SentencePieceTokenizer(sp_model)
    elif os.path.isfile(bpe_model):
        tokenizer = BPETokenizer(bpe_model, config["from"]["code"], config["to"]["code"])
    return {"model": model, "tokenizer": tokenizer}

I tried replacing device="cpu" with device=device , in which case the GPU was used, but I was getting an OOM error.

@pierotofy pierotofy added the enhancement New feature or request label Jan 16, 2024
@pierotofy
Copy link
Member

It makes sense, while using the GPU it probably tries to perform batch translation of all samples at once (which would require a lot of GPU memory).

This would probably require an improvement on OpenNMT to limit the batch size.

@argosopentech
Copy link
Contributor

I've also had some issues trying to get CTranslate2 to run on a GPU.

[email protected]:~/Locomotive$ python3 eval.py --config model-config.json 
Starting interactive mode
(en)> Hello this is a test
Traceback (most recent call last):
  File "/root/Locomotive/eval.py", line 239, in <module>
    translation_obj = data["model"].translate_batch(
RuntimeError: Library libcublas.so.11 is not found or cannot be loaded

https://community.libretranslate.com/t/language-model-training-for-argos-translate-lt-locomotive/717/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants