If your computer reports that GPU memory is full, a game stutters, or a machine-learning task fails with an “out of memory” error, you may be wondering how to clear GPU memory. The right solution depends on what is using the memory: an open application, a background process, a browser tab, or data still held by your code. In most cases, closing the program that allocated the memory is the safest and most effective fix. This guide explains how to check GPU memory usage and free it on Windows, macOS, Linux, and in popular Python frameworks.
What Is GPU Memory?
GPU memory, commonly called VRAM, is the dedicated memory on a graphics card. It holds data the GPU needs to work, such as game textures, video frames, 3D models, and machine-learning data. It is separate from your computer’s system RAM, so closing a regular document or clearing browser history will not necessarily free GPU memory.
GPU memory is allocated while an application is using the graphics card. Some of that memory may be reserved for active work, while some may be held temporarily for faster reuse. A high memory reading is not automatically a problem: games and creative applications often use available VRAM to improve performance. It becomes an issue when another task cannot get the memory it needs, performance drops, or an application reports an error.
How to Check Which Application Is Using GPU Memory
Before clearing GPU memory, identify what is using it. Closing the wrong application can interrupt a download, render, game, or training job. Check your operating system’s GPU tools and look for processes with unusually high dedicated GPU memory usage.
- Windows: Open Task Manager with Ctrl+Shift+Esc. Select the Processes tab, right-click a column heading, and enable GPU and GPU memory if they are not visible. The Performance tab also shows overall GPU memory usage.
-
Linux with an NVIDIA GPU: Open a terminal and run
nvidia-smi. The output shows GPU memory use and the processes associated with the NVIDIA GPU. - Linux with other GPUs: Use your desktop environment’s system monitor, GPU vendor tools, or application-specific monitoring tools. Available commands differ by hardware and driver.
- macOS: Open Activity Monitor and review processes and energy or GPU-related information available on your macOS version. Apple silicon uses unified memory, so GPU activity shares the system’s memory pool.
Remember that the numbers may not match perfectly across tools. Operating systems, drivers, and graphics applications can report reserved or shared memory differently. Use the process list and the application’s own status display together when troubleshooting.
Close the Application Using the GPU
The simplest way to clear GPU memory is to close the application that allocated it. Save your work first, then quit the game, video editor, 3D program, browser, or machine-learning tool normally. Give the system a few seconds to release its resources, then check GPU memory usage again.
If an application has frozen, use Task Manager on Windows, Activity Monitor on macOS, or a system monitor on Linux to end its process. Force-quitting can discard unsaved work, so use it only when the program will not close normally. Avoid ending unfamiliar system processes: some are required by your desktop, display driver, or active applications.
Background programs can use VRAM even when they are not visible on screen. Common examples include game launchers, screen recorders, video-call tools, browser windows, and GPU-accelerated creative apps. Close only the programs you do not need. If the process restarts automatically, check its settings, startup behavior, or related background service rather than repeatedly ending it.
Restart the App, Driver, or Computer
If closing an application does not reduce GPU memory use, reopen it once and check whether its usage returns to normal. A program may have become stuck or may not have released resources properly. Installing an available application update can help if the issue is a known memory leak.
A computer restart is a reliable way to clear GPU memory held by a stuck application or driver. Restarting closes running processes and reloads the graphics driver. Save your work first, since a restart will close open programs. If you do not want to restart the entire computer, signing out and back in may also end user applications, but it is less dependable for a driver or system-level problem.
For recurring issues, update your graphics driver through the graphics-card manufacturer or your computer manufacturer’s recommended channel. Use a clean driver installation only when ordinary updates fail or support guidance recommends it; removing drivers unnecessarily can create display problems.
Clear GPU Memory in Windows
On Windows, start by sorting Task Manager’s Processes list by GPU memory or GPU activity. Quit the application using the most memory, then wait briefly for the number to refresh. If the process is unresponsive, select it and choose End task, keeping in mind that unsaved data may be lost.
You can also reduce GPU memory use by closing extra browser tabs and windows, stopping unneeded video streams, or turning off hardware acceleration in an application that is causing trouble. Hardware acceleration lets software use the GPU for some tasks; disabling it may reduce GPU use but can also make video playback, page rendering, or editing less smooth. Change this setting only if you have a reason, and restart the affected app afterward.
Windows may also show shared GPU memory. This is system RAM that can be made available to the GPU, not additional physical VRAM on your graphics card. You generally cannot clear it with a separate “clear memory” button. Close the programs using it, reduce the workload, or restart if an application is stuck.
Clear GPU Memory on Linux
On NVIDIA systems, nvidia-smi is a useful way to inspect GPU usage. If it lists a process you recognize, close that application normally. If it remains after the application exits, check whether a related process is still running and whether the display server or another program is using the card.
Do not kill a process just because it appears in the list. On a desktop computer, the display server may use the GPU to show your desktop, and stopping it can close your graphical session. If you are working on a remote compute server, confirm that the process belongs to you and that it is safe to stop before taking action.
Some NVIDIA GPUs and systems support a GPU reset through nvidia-smi, but a reset may be unavailable while the GPU is in use and can interrupt every workload on that device. It can also disrupt a desktop session. Use a reset only when you understand the consequences and have administrator permission; restarting the machine is often the safer option. Commands and reset support vary by GPU, driver, and system configuration.
Clear GPU Memory in PyTorch
In PyTorch, first remove references to tensors and models that are no longer needed. Python will not release an object while another variable, list, notebook cell, or function still refers to it. For example, delete unused variables with del variable_name, then run Python’s garbage collector with import gc; gc.collect() if appropriate.
You can then use torch.cuda.empty_cache() to release unused cached GPU memory back to the CUDA allocator so other applications can use it. This function does not free memory occupied by live tensors, and it may not lower the total memory reported by every monitoring tool. PyTorch caches allocations to speed up later operations, so cached memory can still be available for reuse by PyTorch.
If you are in a notebook, restarting the kernel is often the easiest way to release all memory held by that Python session. Save anything you need first. For an out-of-memory error, also try using a smaller batch size, processing data in smaller chunks, or avoiding the storage of unnecessary intermediate results. Clearing the cache alone will not solve a workload that genuinely requires more VRAM than the GPU has available.
Clear GPU Memory in TensorFlow
TensorFlow may reserve GPU memory for its own use, and simply deleting a Python variable does not always return that allocation to the operating system immediately. If you no longer need a model or dataset, remove references to it and allow Python to clean up unused objects. In notebooks, restarting the kernel is a straightforward way to end the session and release its GPU allocations.
For repeated model work, consider using a separate process for each run or configuring TensorFlow’s GPU memory-growth behavior before the GPU is initialized. The exact setup depends on your TensorFlow version and environment. Memory-growth settings control how TensorFlow obtains GPU memory; they do not increase the card’s physical capacity or make an oversized model fit automatically.
Prevent GPU Memory from Filling Up Again
- Close unused GPU applications: Games, editors, browsers, and machine-learning programs can all compete for VRAM.
- Reduce workload size: Lower texture quality, output resolution, model size, or batch size when an application offers those settings.
- Update software: Current application and graphics-driver versions may include fixes for memory leaks and compatibility problems.
- Monitor long-running tasks: Watch GPU usage during repeated renders, training runs, or long sessions to spot a gradual increase.
- Restart a misbehaving process: If memory use keeps climbing without a clear reason, save your work and restart the affected application.
For machine learning, optimize the workload before relying on frequent cache clearing. Smaller batches, mixed-precision computation where supported, and releasing unneeded tensors can reduce peak memory demand. For games and creative software, lowering demanding graphics or project settings is often more effective than repeatedly restarting the computer.
Conclusion
To clear GPU memory, first find the application using it and close that application normally. If memory remains occupied, check for background processes, restart the affected program, or reboot the computer to reset the graphics driver and release stuck allocations. In PyTorch and TensorFlow, remove unused objects or restart the session; remember that cache-clearing functions cannot free memory still needed by live tensors. By identifying the cause and reducing unnecessary GPU workloads, you can resolve memory errors and help prevent them from returning.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.