Skip to content

multiple GPUs #360

Answered by jongwook
Michl87 asked this question in Q&A
Oct 18, 2022 · 4 comments · 10 replies
Discussion options

You must be logged in to vote

It's possible to load the encoder on one GPU and the decoder on the other, with a bit of hack:

First, please update the package so it has the latest commit (I made a minor modification for this):

pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git

And then something like this is possible:

import whisper

model = whisper.load_model("large", device="cpu")

model.encoder.to("cuda:0")
model.decoder.to("cuda:1")

model.decoder.register_forward_pre_hook(lambda _, inputs: tuple([inputs[0].to("cuda:1"), inputs[1].to("cuda:1")] + list(inputs[2:])))
model.decoder.register_forward_hook(lambda _, inputs, outputs: outputs.to("cuda:0"))

model.transcribe("jfk.flac")

Replies: 4 comments 10 replies

Comment options

You must be logged in to vote
3 replies
@a-ruban
Comment options

@Michl87
Comment options

@Dragonslayersakata
Comment options

Comment options

You must be logged in to vote
4 replies
@tcl8273
Comment options

@jongwook
Comment options

@silvacarl2
Comment options

@FNG654
Comment options

Answer selected by jongwook
Comment options

You must be logged in to vote
3 replies
@richardliaw
Comment options

@kristopher-smith
Comment options

@jake1271
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet