Title: CUDA Support — PyTorch main documentation
Description: PyTorch CUDA C++ API — device management, streams, guards, and cuDNN/cuBLAS utilities.
Keywords:
Domain: docs.pytorch.org
{
"@context": "https://schema.org",
"@type": "Article",
"name": "CUDA Support",
"headline": "CUDA Support",
"description": "PyTorch CUDA C++ API \u2014 device management, streams, guards, and cuDNN/cuBLAS utilities.",
"url": "/api/cuda/index.html",
"articleBody": "CUDA Support# PyTorch provides comprehensive CUDA support for GPU-accelerated tensor operations and neural network training. The CUDA API allows you to manage GPU devices, streams for asynchronous execution, and memory efficiently. When to use CUDA APIs: When you need explicit control over which GPU device to use When implementing custom CUDA kernels or operations When optimizing performance with asynchronous stream execution When managing multi-GPU workloads Basic usage: #include \u003ctorch/torch.h\u003e #include \u003cc10/cuda/CUDAGuard.h\u003e // Check if CUDA is available if (torch::cuda::is_available()) { // Create tensor on GPU auto tensor = torch::randn({2, 3}, torch::device(torch::kCUDA)); // Switch to a specific GPU c10::cuda::CUDAGuard guard(0); // Use GPU 0 // Get the current CUDA stream auto stream = c10::cuda::getCurrentCUDAStream(); // Move model to GPU model-\u003eto(torch::kCUDA); } Header Files# c10/cuda/CUDAStream.h - CUDA stream management c10/cuda/CUDAGuard.h - CUDA device guards ATen/cuda/CUDAContext.h - CUDA context management ATen/cudnn/Descriptors.h - cuDNN tensor descriptors CUDA Categories# CUDA Streams CUDA Guards CUDA Utility Functions",
"author": {
"@type": "Organization",
"name": "PyTorch Contributors",
"url": "https://pytorch.org"
},
"image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "/api/cuda/index.html"
},
"datePublished": "2023-01-01T00:00:00Z",
"dateModified": "2023-01-01T00:00:00Z"
}
| docsearch:language | en |
| llm:site-type | documentation |
| llm:framework | PyTorch |
| llm:description | PyTorch CUDA C++ API — device management, streams, guards, and cuDNN/cuBLAS utilities. |
| llm:navigation-file | https://pytorch.org/docs/stable/llms.txt |
| llm:sitemap | https://pytorch.org/docs/stable/sitemap.xml |
| llm:version | main |
| llm:project | PyTorch |
| llm:page-type | documentation |
| og:image | https://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png |
| None | 2 |
Links:
Viewport: width=device-width, initial-scale=1