python - pytorch when do I need to use `.to(device)` on a model or tensor? - Stack Overflow
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Find centralized, trusted content and collaborate around the technologies you use most. Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Get early access and see previews of new features. I am new to Pytorch, but it seems pretty nice. My only question was when to use tensor.to(device) or Module.nn.to(device). I was reading the documentation on this topic, and it indicates that this method will move the tensor or model to the specified device. But I was not clear for what operations this is necessary, and what kind of errors I will get if I don't use .to() at the right time? For example, if I just create a tensor, I imagine that the tensor is stored in CPU accessible memory until I move the tensor to the GPU. Once the tensor is on the GPU, then the GPU will execute any mathematical operations on that tensor. However, d
python - pytorch when do I need to use `.to(device)` on a model or tensor? - Stack Overflow The 2026 Annual Developer Survey is live— take the Survey today! Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives Stack Internal Knowledge at work Bring the best of human thought and AI automation together at your work. Explore Stack Internal pytorch when do I need to use `.to(device)` on a model or tensor? Ask Question Asked 6 years ago Modified 2 years, 8 months ago Viewed 107k times 50 I am new t
Explore this link on the map →related reading
- Tensors — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- PyTorch internals : ezyang's blogblog.ezyang.com
- Tensors — PyTorch Tutorials 2.13.0+cu130 documentationdocs.pytorch.org
- PiTorch: ML on Baremetal Raspberry Pis | projectsmasonjwang.com
- Making Deep Learning go Brrrr From First Principleshorace.io
- the bug that taught me more about PyTorch than years of using it | Elana Simonelanapearl.github.io
- PyTorch Inference | onnxruntimeonnxruntime.ai
- PyTorch (@PyTorch) / Xx.com
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- Learning PyTorch with Examples — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- Chapter 0: Fundamentals - ARENAlearn.arena.education
- The Best GPUs for Deep Learning in 2023 — An In-depth Analysistimdettmers.com