What does model.eval() do in pytorch?
When should I use .eval() ? I understand it is supposed to allow me to "evaluate my model". How do I turn it back off for training? Example training code using .eval() .
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
When should I use .eval() ? I understand it is supposed to allow me to "evaluate my model". How do I turn it back off for training? Example training code using .eval() .
I am trying to initialize a tensor on Google Colab with GPU enabled. device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') t = torch.tensor([1,2], device=device) But I am getting this strange error. RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously reported at some other API call,so the stacktra
The torch.profiler.profile context manager provides detailed operator-level latency and memory consumption data via Kineto integration. While the profiler includes a schedule configuration to mitigate initial warmup overhead, the measurement accuracy for extremely small, high-frequency operators remains a concern. When capturing traces for models with many l
In PyTorch Distributed Data Parallel (DDP), the find_unused_parameters flag is used to handle models where some parameters do not contribute to the loss in every forward pass. When enabled, DDP must traverse the autograd graph to identify these unused parameters and exclude them from the all-reduce synchronization process. While this ensures correctness for
Goal: Achieve deterministic batch ordering when using torch.utils.data.DataLoader with num_workers>0 while preserving the performance benefits of multiprocess data loading. Constraint: Setting a global seed via torch.manual_seed does not propagate uniquely to each worker, so workers may generate identical augmentation sequences unless a worker_init_fn is
Choosing between file‑based fixtures and in‑memory tensor factories for credential‑free PyTorch unit tests The goal is to design a test strategy that avoids production credentials while keeping test execution fast and reliable. Using torch.save to persist tensors to temporary files allows tests to reuse pre‑generated checkpoints without network access, but f
I'm trying to run Pytorch on a laptop that I have. It's an older model but it does have an Nvidia graphics card. I realize it is probably not going to be sufficient for real machine learning but I am trying to do it so I can learn the process of getting CUDA installed. I have followed the steps on the installation guide for Ubuntu 18.04 (my specific distribu
Goal: obtain identical interpolation outputs from torch.nn.functional.interpolate with mode='bilinear' and the default align_corners=None when running the same model on CPU and CUDA devices. Constraint: the default value leaves the interpolation kernel unspecified, causing the CPU and CUDA backends to use different resampling schemes, which produces non‑iden
Gradient Accumulation Behavior PyTorch supports simulating larger batch sizes by summing gradients over multiple forward and backward passes before executing an optimizer step. This technique is intended to keep memory consumption proportional to the micro-batch size rather than the effective total batch size. While the .grad attribute accumulates values acr