Inference on multi GPUs
I am using 8 A6000 GPUs for a text-to-image inference task. I deployed the model across multiple GPUs usingdevice_map="auto", but when the inference begins, an error occurs stating that GPU 0 doesn’t have enough memory. Is this a mechanism inherent to the model’s inference process, where the additional memory overhead during inference is primarily handled by the first GPU?model = Qwen2VLForConditionalGeneration.from_pretrained(
    "Qwen/Qwen2-VL-7B-Instruct",
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
...
inputs = processor(
        text=[text],
        images=image_inputs,
        videos=video_inputs,
        padding=True,
        return_tensors="pt",
    )
    inputs = inputs.to("cuda")

    generated_ids = model.generate(**inputs, max_new_tokens=128)
    generated_ids_trimmed = [
        out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
    ]
    output_text = processor.batch_decode(
        generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
    )image1282×125 8.51 KB