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

feat: send pipeline to device with Pipeline.to(device) #1204

Merged
merged 9 commits into from
Jan 3, 2023

Conversation

hbredin
Copy link
Member

@hbredin hbredin commented Dec 21, 2022

@codecov
Copy link

codecov bot commented Dec 21, 2022

Codecov Report

Base: 29.91% // Head: 29.75% // Decreases project coverage by -0.16% ⚠️

Coverage data is based on head (79845fb) compared to base (7a60da9).
Patch coverage: 14.28% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1204      +/-   ##
===========================================
- Coverage    29.91%   29.75%   -0.17%     
===========================================
  Files           62       62              
  Lines         3817     3872      +55     
===========================================
+ Hits          1142     1152      +10     
- Misses        2675     2720      +45     
Impacted Files Coverage Δ
pyannote/audio/pipelines/multilabel.py 0.00% <0.00%> (ø)
...ote/audio/pipelines/overlapped_speech_detection.py 0.00% <0.00%> (ø)
pyannote/audio/pipelines/resegmentation.py 0.00% <ø> (ø)
pyannote/audio/pipelines/segmentation.py 0.00% <ø> (ø)
pyannote/audio/pipelines/speaker_diarization.py 0.00% <ø> (ø)
pyannote/audio/pipelines/speaker_verification.py 0.00% <0.00%> (ø)
...annote/audio/pipelines/voice_activity_detection.py 0.00% <ø> (ø)
pyannote/audio/core/pipeline.py 21.98% <15.51%> (-6.25%) ⬇️
pyannote/audio/core/inference.py 61.42% <57.14%> (-0.34%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hbredin hbredin merged commit 40783ce into develop Jan 3, 2023
@hbredin hbredin deleted the feat/send_pipeline_to_device branch January 3, 2023 12:44
@prashanthellina
Copy link
Contributor

@hbredin When I run the speaker diarization pipeline on latest develop branch, the GPU is not being used for embeddings computation (it used to work before the changes from this PR).

I suspect this piece of code in speaker_verification.py file.

run_opts={"device": self.device},

When I change self.device to device, it works as expected.

@hbredin
Copy link
Member Author

hbredin commented Jan 5, 2023

Good catch. Would you make a PR?

@prashanthellina
Copy link
Contributor

Sure, Will do.

@prashanthellina
Copy link
Contributor

@hbredin #1217

@maxiek0071
Copy link

maxiek0071 commented Feb 9, 2023

@hbredin

Would you mind telling how do I call pipeline.to(device) to decode on CPU?

This is my code:

from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization",
                                    use_auth_token="<my_token>")
pipeline.to("cpu")

and am getting this error:

  File "transcription_module/my_custom_example.py", line 18, in <module>
    pipeline = pipeline.to("cpu")
  File "/home/ubuntu/.local/lib/python3.7/site-packages/pyannote/pipeline/pipeline.py", line 100, in __getattr__
    raise AttributeError(msg)
AttributeError: 'SpeakerDiarization' object has no attribute 'to'

@hbredin
Copy link
Member Author

hbredin commented Feb 9, 2023

Pipeline.to API has not been released yet.

Install pyannote.audio from develop branch and it should work.

@maxiek0071
Copy link

Thanks, it works now!

@hbredin hbredin mentioned this pull request Mar 5, 2023
@lasagna0
Copy link

lasagna0 commented Mar 7, 2023

Hey, for me its not working when using pip install https://github.com/pyannote/pyannote-audio/archive/refs/heads/develop.zip

@donzthefonz
Copy link

I'm running Mac M1 and think I've installed the develop branch by running pip install git+https://github.com/pyannote/pyannote-audio.git@develop#egg=pyannote-audio

Does this mean it should automatically use the gpu/mps or do I have to manually set with Pipeline.to("mps")?

The diarization step is still taking longer than I would have expected it to. Though the audio file is 1.5 hours long...

@hbredin
Copy link
Member Author

hbredin commented Mar 13, 2023

It will run on CPU by default.

@Qualzz
Copy link

Qualzz commented Apr 26, 2023

Took me a while to notice this post. Nothing would work until I manually add pipeline.to(device) to my code.

Is there any reason why it doesn't use the GPU by default (as written in the README) since CPU would be extremely slow nonetheless ?

Maybe i'm stupid, but I lost hours waiting the process to complete while it would took 300x less with my GPU. Tried multiple torch install, etc.

@lyehe
Copy link

lyehe commented Jun 11, 2023

Im having the same issue. The pipeline is running on the CPU by default.
BTW, I also tried pipeline.to(device), which broke the kernel.

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

Successfully merging this pull request may close these issues.

None yet

7 participants