Changing the device of Pipeline

I have loaded a pipeline on a device (or cpu):

gen = pipeline('text-generation', model=m_path, device=0)

Now I’d like to move it to another device (or cpu). What is the right way of doing it?

You could always move the model using gen.model.to("cuda:1") for instance to move it to the second GPU

1 Like