# Pipe.to("cuda") not working

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipe-to-cuda-not-working%2F30952%3E%5C
**Category:** Beginners\
**Created:** [February 2, 2023, 12:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipe-to-cuda-not-working%2F30952 "2023-02-02T00:35:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterB123A](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/peterb123a/32/11792_2.png) [@PeterB123A](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FPeterB123A)%5C
**Post date:** [February 2, 2023, 12:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipe-to-cuda-not-working%2F30952%2F1 "2023-02-02T00:35:13Z")

</div>

I’m using latest nvidea studio drivers  
Pytorch cuda works on WSL ubuntu however i cannot run pipe.to(“cuda”) with stable difusion.

# inside jupyterlab cell

from huggingface\_hub import notebook\_login  
notebook\_login() # ← **although i enter my key hf\_asfasfd… i cannot verify login is accepted**

device = torch.device(“cuda” if torch.cuda.is\_available() else “cpu”)  
print(device) # → **reports cuda**

# in another cell

import torch  
from diffusers import StableDiffusionPipeline  
from PIL import Image

pipe = StableDiffusionPipeline.from\_pretrained(“runwayml/stable-diffusion-v1-5”, torch\_dtype=torch.float16) # ← **i can see it downloaded the model so login was OK i guess**  
pipe = pipe.to(“cuda”) # ← **kernel time out i got a 3080TX memmory stays low no indication it loaded**

prompt = “a photo of a cat riding a horse on mars”  
image = pipe(prompt).images[0]

image.show()

I have altered the config to perform kernel restart after 10 minutes to wait if it takes longer but this has no effect ( when the kernel dies eventually on the linux prompt i get AsyncIOLoopKernelRestarter: restarting kernel ) but no other errors on the screen or on the web page of the notebook.

---

<div class="post-metadata">

**Author:** ![wayandadang](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/wayandadang/32/26282_2.png) [@wayandadang](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fwayandadang)%5C
**Post date:** [April 27, 2024, 12:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipe-to-cuda-not-working%2F30952%2F2 "2024-04-27T12:59:15Z")

</div>

I found there’s an update pipe for parallel computing using GPU, use this to improve it,

Original code:  
pipe.to(“gpu”)

Then replace with:  
pipe.to(device=“cuda”, dtype=torch.float16)
