PaddlePaddle/PaddleOCR · error · ValueError
ProfilerOptions does not have an option named %s.
Error message
ProfilerOptions does not have an option named %s.
What it means
ValueError from ProfilerOptions.__getitem__ (ppocr/utils/profiler.py): looking up an option that was never set into self._options returns None and raises. Options are populated from the profiler options string (state, sorted_key, tracer_option, profile_path, exit_on_finished, timer_only, and the numeric list options), so any other name — or a valid name whose parsed value never landed in _options — triggers this.
Source
Thrown at ppocr/utils/profiler.py:83
if key == "batch_range":
value_list = value.replace("[", "").replace("]", "").split(",")
value_list = list(map(int, value_list))
if (
len(value_list) >= 2
and value_list[0] >= 0
and value_list[1] > value_list[0]
):
self._options[key] = value_list
elif key == "exit_on_finished":
self._options[key] = value.lower() in ("yes", "true", "t", "1")
elif key in ["state", "sorted_key", "tracer_option", "profile_path"]:
self._options[key] = value
elif key == "timer_only":
self._options[key] = value
def __getitem__(self, name):
if self._options.get(name, None) is None:
raise ValueError("ProfilerOptions does not have an option named %s." % name)
return self._options[name]
def add_profiler_step(options_str=None):
"""
Enable the operator-level timing using PaddlePaddle's profiler.
The profiler uses a independent variable to count the profiler steps.
One call of this function is treated as a profiler step.
Args:
profiler_options - a string to initialize the ProfilerOptions.
Default is None, and the profiler is disabled.
"""
if options_str is None:
return
global _prof
global _profiler_step_id
global _profiler_optionsView on GitHub (pinned to 2661c7c0ef)
Solutions
- Restrict keys in the profiler options string to the supported set: state, sorted_key, tracer_option, profile_path, exit_on_finished, timer_only (plus the documented numeric list options).
- Use opts.get(name) style access or check 'name in opts._options' instead of opts[name] when a default is acceptable.
- Run with no profiler options first to confirm profiling works, then add options one at a time.
Example fix
# before
opts = ProfilerOptions('state:OP')
path = opts['profile_path'] # never set -> ValueError
# after
path = opts._options.get('profile_path', './profile_output') Defensive patterns
Strategy: validation
Validate before calling
KNOWN_OPTIONS = {"state", "sorted_key", "tracer_option", "profile_path", "exit_on_finished", "timer_only"}
keys = {kv.split(':')[0] for kv in options_str.split() if ':' in kv}
unknown = keys - KNOWN_OPTIONS
assert not unknown, f"unsupported profiler options: {unknown}; supported: {sorted(KNOWN_OPTIONS)}" Type guard
def is_known_profiler_option(name) -> bool:
return name in {"state", "sorted_key", "tracer_option", "profile_path", "exit_on_finished", "timer_only"} Prevention
- Access ProfilerOptions via .get-style lookup (opts._options.get(name)) instead of opts[name] when defaults are acceptable.
- Validate the profiler options string once at startup rather than per step.
When it happens
Trigger: Passing a --profiler-options string with an unsupported key, or user code doing profiler_opts['missing_key']; also when a key like profile_path is expected to have a default but none was supplied in the options string.
Common situations: Enabling operator-level profiling (tools/infer/predict.py or train with profiler options) with key names copied from paddle's newer/older profiler API rather than this wrapper's accepted set; typos like 'sorted_keys'.
Related errors
- RecResizeImg.image_shape is required in rec inference.yml
- Unexpected recognition channels: ${String(channels)}
- OCR pipeline config text must decode to an object.
- OCR pipeline config must be an object or YAML text.
- ${modulePath}.model_name must be provided when ${modulePath}
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/3d33672788d6fbd5.
Report an issue: GitHub.