How to convert .ckpt to .pb?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Converting a TensorFlow checkpoint into a .pb file usually means restoring trained variables and freezing them into a graph that can be used for inference. This is mainly a TensorFlow 1.x workflow, so the first thing to confirm is whether you truly need a legacy .pb graph or whether a modern SavedModel export would be more appropriate.
Understand what the two files represent
A checkpoint stores variable values. It does not, by itself, represent a complete standalone inference artifact. A .pb file, by contrast, usually stores a serialized graph definition, and in the frozen-graph case it also contains the weights embedded as constants.
That means a checkpoint is not enough on its own. To freeze it correctly, you generally need:
- the graph structure
- the checkpoint path
- the output node names used for inference
Without the output node names, TensorFlow cannot know which parts of the graph should be preserved in the final exported file.
Classic TensorFlow 1.x freezing flow
A compatibility-style conversion looks like this:
This restores the checkpoint, turns variables into constants, and writes the final .pb graph.
Finding the right output node names
Output node names are often the hardest part of the conversion. If you are not sure what they are, inspect the graph operations after restoring it:
The goal is to keep only the graph needed to compute your real inference outputs. If you freeze the wrong nodes, the .pb file may load successfully while still being useless for inference. In practice, spending time on node inspection usually saves more time than blindly retrying exports.
Loading the frozen graph later
A classic load path for the resulting .pb file looks like this:
This is the older inference-side pattern for graph-based TensorFlow deployments.
When SavedModel is the better answer
If you are working with TensorFlow 2.x or a Keras model, direct .ckpt to .pb conversion is often not the best path. In many modern projects, the right export is simply:
That produces a SavedModel, which is easier to serve and maintain in current TensorFlow workflows. It also preserves more model metadata and signatures than a raw frozen graph workflow usually does. Many requests for .ckpt to .pb come from legacy tutorials or downstream tooling that still expects frozen graphs.
Common Pitfalls
- Assuming a checkpoint already contains the full deployable model.
- Forgetting that the graph structure and output node names are required for freezing.
- Using the wrong output node names and exporting the wrong slice of the graph.
- Applying old TensorFlow
1.xfreezing steps to a modern2.xmodel whenSavedModelwould be simpler.
Summary
- Converting
.ckptto.pbusually means restoring a graph and freezing variables into constants. - You need the graph structure, checkpoint path, and correct output node names.
- This is primarily a TensorFlow
1.xworkflow. - In modern TensorFlow projects,
SavedModelis usually the better export target unless legacy tooling requires.pb.

