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

CUDA initialization error for faster whisper in subprocess #983

Open
FengJi2021 opened this issue Aug 30, 2024 · 0 comments
Open

CUDA initialization error for faster whisper in subprocess #983

FengJi2021 opened this issue Aug 30, 2024 · 0 comments

Comments

@FengJi2021
Copy link

How to reproduce:

import traceback
from faster_whisper import WhisperModel
import multiprocessing as mp
import torch

if __name__ == "__main__":
    torch.cuda.is_available()
    def sub():
        try:
            w = WhisperModel(
                model_size_or_path="tiny", 
                device="cuda", 
                compute_type="float32"
            )
        except:
            traceback.print_exc()
        finally:
            exit(0)
    try:
        p = mp.Process(
            target=sub,
        )
        p.start()
        p.join()
    finally:
        p.terminate()

Run this script will produce

self.model = ctranslate2.models.Whisper(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA failed with error initialization error

The reason

cuda can not be re-initialized in a forked subprocess.
CUDA Multiprocessing ISSUE

Suggestion

Faster whisper check if cuda already initialized before do it.

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

No branches or pull requests

1 participant