employer cover photo
employer logo
employer logo

Boston University

Is this your company?

Boston University Interview Question

How to handle out-of-memory errors on a GPU?

Interview Answer

Anonymous

Nov 24, 2025

Monitoring Memory Usage: PyTorch provides tools like torch.cuda.max_memory_allocated() and torch.cuda.max_memory_cached() to monitor the highest levels of memory allocation and caching on the GPU. Additionally, nvidia-smi and NSight are great utilities for overall performance monitoring. Memory Clearance: PyTorch supplies the torch.cuda.empty_cache() function, which aids in releasing GPU memory that is no longer in use.