Ravindra BagaleCourses & study guides English Track your progress

44. Install PyTorch and First Tensors

Data Science

44.4 CPU vs GPU Note

44.4 CPU vs GPU note

“GPU लागतं का?” — या chapters साठी नाही.

हे का शिकायचं?

Why. लोक विचारतात: “या chapters साठी GPU लागतं का?”

हे काय आहे?

What. Tiny demos साठी CPU पुरेसं. मोठ्या images / batches साठी GPU मदत करते. CUDA असेल तर .to(device) ने tensor move करता येतो.

कसं करायचं?

How.

Device snippet

  1. Available असेल तर cuda, नाहीतर cpu.
  2. त्या device वर tensor create करा.
  3. Model + data दोन्ही same device वर ठेवा.
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
x = torch.ones(2, 2, device=device)
print(device, x)

India lab reality. अनेक training rooms फक्त CPU. या block मधले सगळे copy-run samples CPU साठी sized आहेत.

Many training rooms are CPU-only. Every copy-run sample in this block is sized for CPU.