question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement `pipeline.to(device)`

See original GitHub issue

Currently, pipeline modules are moved to the preferred compute device during __call__. This is reasonable, as they stay there as long as the user keeps passing the same torch_device across calls.

However, in multi-GPU model-serving scenarios, it could be useful to move each pipeline to a dedicated device during or immediately after instantiation. This would make it possible to create, say, 8 different pipelines and move each one to a different GPU. Doing it this way could potentially save CPU memory while preparing the service.

Currently, the workaround to achieve the same would be to perform a call with fake data immediately after the instantiation.

Describe the solution you’d like Ideally, the following should work:

pipe = StableDiffusionPipeline.from_pretrained(model_id).to("cuda:1")

Describe alternatives you’ve considered Current workaround:

pipe = StableDiffusionPipeline.from_pretrained(model_id)
_ = pipe(["cat"], num_inference_steps=1, torch_device="cuda:1")

Another alternative would be to pass the device to the initializer. This could be done in addition to adding a to method, but I believe it’s not necessary as to is familiar enough to PyTorch users.

Additional context See discussion in this Slack thread.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pcuencacommented, Aug 17, 2022

@patil-suraj happy to take it! I’ll do it after making some progress on the backend, unless it’s urgent. I think I’d be ready to work on this later today or tomorrow, would that be ok?

0reactions
patil-surajcommented, Aug 17, 2022

@pcuenca do you wanna take a stab at it ? Otherwise happy to work on it, if you are busy 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipelines - Hugging Face
The pipelines are a great and easy way to use models for inference. These pipelines are objects that abstract most of the complex...
Read more >
How to Use Transformers pipeline with multiple GPUs #15799
Is there anyway to set the pipeline to use multiple gpus? So I could use something like. os.environ["CUDA_VISIBLE_DEVICES"] = "0,1" device ...
Read more >
Tutorial: Create a pipeline that builds and tests your Android ...
Learn how to use AWS CodePipeline to build your Android app with CodeBuild and test it with AWS Device Farm every time you...
Read more >
Azure IoT Edge | Microsoft Learn
This article demonstrates how you can use Azure Pipelines to build, test, and deploy Azure IoT Edge modules using YAML.
Read more >
3. Pipelining — Model Parallelism on the IPU with TensorFlow
You can use the device mapping API to assign pipeline stages which use the same variable to be on the same IPU. 3.3.3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found