Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Huggingface Optimum EnvironmentCommand

From Leeroopedia
Knowledge Sources
Domains CLI, Diagnostics
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for displaying Optimum runtime environment information (package versions, platform, GPU availability) provided by the Huggingface Optimum CLI.

Description

EnvironmentCommand is a leaf CLI command registered under `optimum-cli env`. When run, it collects version information for `optimum`, `transformers`, `huggingface_hub`, and `torch`, along with platform and Python version details. The output is formatted for copy-pasting into GitHub issue reports.

Usage

Run `optimum-cli env` from the terminal to display the current environment configuration. This is primarily used for debugging and issue reporting.

Code Reference

Source Location

Signature

class EnvironmentCommand(BaseOptimumCLICommand):
    COMMAND = CommandInfo(name="env", help="Get information about the environment used.")

    @staticmethod
    def format_dict(d):
        """Format a dictionary as a bullet-point list string."""

    def run(self):
        """Collect and print environment information.

        Returns:
            dict: Dictionary containing version and platform information.
        """

Import

from optimum.commands.env import EnvironmentCommand

I/O Contract

Inputs

Name Type Required Description
(none) No additional inputs; environment is introspected at runtime

Outputs

Name Type Description
run() returns dict Dictionary with keys: optimum version, transformers version, Platform, Python version, huggingface_hub version, PyTorch version
stdout str Formatted environment info printed to console

Usage Examples

Command Line

optimum-cli env

Programmatic Usage

from optimum.commands.env import EnvironmentCommand

# EnvironmentCommand is typically invoked via the CLI, but can be used programmatically
cmd = EnvironmentCommand.__new__(EnvironmentCommand)
info = cmd.run()
print(info)
# {'`optimum` version': '1.x.x', '`transformers` version': '4.x.x', ...}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment