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
Reproducible Execution in Multi-Backend Environments Keras 3 provides keras.config.enable_determinism() to ensure consistent model behavior across different runs. While this configuration manages high-level settings, the underlying execution depends on the active backend (TensorFlow, JAX, or PyTorch). There is uncertainty regarding how this global Keras flag
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
I'm setting up automatic mixed precision training with torch.autocast and torch.cuda.amp.GradScaler and want to make a deliberate choice between two documented configurations: float16 autocast with gradient scaling, or bfloat16 autocast without it. My understanding is that bfloat16's wider exponent range usually makes the scaler unnecessary, while float16 ne
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
PyTorch's torch.distributed.all_gather collective returns tensors from all ranks, but the order of the returned list is unspecified. This is a documented failure condition for any workflow that assumes a fixed rank-to-index mapping, including deterministic gradient aggregation and parameter synchronization across processes. Because the ordering is not guaran
For a low-traffic PyTorch 2.x inference service, the design goal is to reduce per-request memory and compute overhead without breaking model code that depends on autograd. The documented torch.inference_mode() context manager suppresses autograd recording and view/version tracking, but its inference tensors have restrictions that differ from torch.no_grad()
Goal Determine a safe, version‑agnostic method for loading existing PyTorch checkpoints that were saved with the legacy torch.load behavior (weights_only=False) while the default has shifted to weights_only=True in recent releases. Constraints include preserving the ability to load trusted checkpoints that contain non‑tensor Python objects (e.g., custom opti