← All notes

CUDA semantics in PyTorch

Answer: torch.cuda is used to set up and run CUDA operations. It keeps track of the currently selected GPU, and all CUDA tensors you allocate will by default be created on that device. (S1)

Devices

Asynchrony and memory

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PyTorch docs, CUDA semantics — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed; PyTorch docs, torch.cuda — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed.

Cite this

Permanent ID: iil:note:e3yw4d3d

iinventedlight. 2026. "CUDA semantics in PyTorch." iinventedlight Library, iil:note:e3yw4d3d, version of 2026-11-04. https://iinventedlight.com/library/notes/pytorch-cuda-semantics/. License: CC-BY-4.0.

@misc{iil_note_e3yw4d3d,
  author = {{iinventedlight}},
  title = {{CUDA semantics in PyTorch}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/pytorch-cuda-semantics/},
  note = {Permanent ID iil:note:e3yw4d3d. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/pytorch-cuda-semantics.md.