OS Manuals

/usr/share/tensorflow/bin/tf_upgrade_v2

tensorflow-gpu

From tensorflow-gpu-jupyter 2.21.0-r18 (extra-packages), captured 2026-11-10 by running tf_upgrade_v2 --help (exit 0). permalink

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1794319960.181728       2 cpu_feature_guard.cc:227] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
usage: tf_upgrade_v2 [-h] [--infile INPUT_FILE] [--outfile OUTPUT_FILE] [--intree INPUT_TREE]
                     [--outtree OUTPUT_TREE] [--copyotherfiles COPY_OTHER_FILES] [--inplace]
                     [--no_import_rename] [--no_upgrade_compat_v1_import]
                     [--reportfile REPORT_FILENAME] [--mode {DEFAULT,SAFETY}] [--print_all]

Convert a TensorFlow Python file from 1.x to 2.0

Simple usage:
  tf_upgrade_v2.py --infile foo.py --outfile bar.py
  tf_upgrade_v2.py --infile foo.ipynb --outfile bar.ipynb
  tf_upgrade_v2.py --intree ~/code/old --outtree ~/code/new

options:
  -h, --help            show this help message and exit
  --infile INPUT_FILE   If converting a single file, the name of the file to convert
  --outfile OUTPUT_FILE
                        If converting a single file, the output filename.
  --intree INPUT_TREE   If converting a whole tree of files, the directory to read from (relative
                        or absolute).
  --outtree OUTPUT_TREE
                        If converting a whole tree of files, the output directory (relative or
                        absolute).
  --copyotherfiles COPY_OTHER_FILES
                        If converting a whole tree of files, whether to copy the other files.
  --inplace             If converting a set of files, whether to allow the conversion to be
                        performed on the input files.
  --no_import_rename    Not to rename import to compat.v2 explicitly.
  --no_upgrade_compat_v1_import
                        If specified, don't upgrade explicit imports of `tensorflow.compat.v1 as
                        tf` to the v2 APIs. Otherwise, explicit imports of the form
                        `tensorflow.compat.v1 as tf` will be upgraded.
  --reportfile REPORT_FILENAME
                        The name of the file where the report log is stored.(default: report.txt)
  --mode {DEFAULT,SAFETY}
                        Upgrade script mode. Supported modes: DEFAULT: Perform only
                        straightforward conversions to upgrade to 2.0. In more difficult cases,
                        switch to use compat.v1. SAFETY: Keep 1.* code intact and import compat.v1
                        module.
  --print_all           Print full log to stdout instead of just printing errors
Options (12)
OptionDescriptionSource
-h, --helpshow this help message and exithelp
--infile INPUT_FILEIf converting a single file, the name of the file to converthelp
--outfile OUTPUT_FILEIf converting a single file, the output filename.help
--intree INPUT_TREEIf converting a whole tree of files, the directory to read from (relative or absolute).help
--outtree OUTPUT_TREEIf converting a whole tree of files, the output directory (relative or absolute).help
--copyotherfiles COPY_OTHER_FILESIf converting a whole tree of files, whether to copy the other files.help
--inplaceIf converting a set of files, whether to allow the conversion to be performed on the input files.help
--no_import_renameNot to rename import to compat.v2 explicitly.help
--no_upgrade_compat_v1_importIf specified, don't upgrade explicit imports of `tensorflow.compat.v1 as tf` to the v2 APIs.help
--reportfile REPORT_FILENAMEThe name of the file where the report log is stored.(default: report.txt)help
--mode DEFAULTUpgrade script mode.help
--print_allPrint full log to stdout instead of just printing errorshelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.