Load CLIP pretrained model on GPU

I’m using the CLIP for finding similarities between text and image but I realized the pretrained models are loading on CPU but I want to load it on GPU since in CPU is not fast. How can I load them on GPU?

model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")

processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")

Thanks!

Here’s how you can put a model on GPU (same for any PyTorch model):

import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
model.to(device)

Yes but my issue is with the second line. I tried to send it to GPU but I cannot 'CLIPProcessor' object has no attribute 'cuda' and for running the code on GPU I need to send both model and processor on GPU

processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")

Do you know how can I send the CLIPProcessor to the GPU?

You cannot move a processor to the GPU. It is meant to prepare data for the model.

The only things you need to move to the GPU are the model and the data.