# .to("cuda"),The model cannot be moved to the GPU

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fto-cuda-the-model-cannot-be-moved-to-the-gpu%2F163167%3E%5C
**Category:** Spaces\
**Created:** [July 15, 2025, 6:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fto-cuda-the-model-cannot-be-moved-to-the-gpu%2F163167 "2025-07-15T18:45:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pique0202](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@pique0202](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpique0202)%5C
**Post date:** [July 15, 2025, 6:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fto-cuda-the-model-cannot-be-moved-to-the-gpu%2F163167%2F1 "2025-07-15T18:45:51Z")

</div>

this is my code,my envs :pytorch == 2.7.1,cuda=12.8 python==3.11,ubuntu20.04, 4090-24G  
After testing, I found that the model couldn’t be moved to the GPU. The.to(" cuda ") operation couldn’t be carried out and was stuck at this step, but no error was reported

```python
import torch
from diffusers import FluxFillPipeline
from diffusers.utils import load_image

image = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cup.png")
mask = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cup_mask.png")
#device = "cuda" if torch.cuda.is_available() else "cpu"

print("Loading model...")
pipe = FluxFillPipeline.from_pretrained("black-forest-labs/FLUX.1-Fill-dev", torch_dtype=torch.bfloat16)
print("Moving to GPU")
pipe = pipe.to("cuda")

print("Has moving to GPU ")

print("Model loaded successfully!")

print("Starting inference...")
image = pipe(
    prompt="a white paper cup",
    image=image,
    mask_image=mask,
    height=1632,
    width=1232,
    guidance_scale=30,
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator("cpu").manual_seed(0)
).images[0]

print("Inference completed.")
image.save(f"flux-fill-dev.png")

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [July 15, 2025, 11:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fto-cuda-the-model-cannot-be-moved-to-the-gpu%2F163167%2F2 "2025-07-15T23:42:51Z")

</div>

> 4090-24G

It has three times the VRAM of my GPU, but this is the reason. FLUX is approximately 36 GB in size. Let’s quantize it.

> **[Exploring Quantization Backends in Diffusers](https://huggingface.co/blog/diffusers-quantization)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Reduce memory usage](https://huggingface.co/docs/diffusers/main/en/optimization/memory)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.
