From bebc166ca999039f426eb3f91b4b100470910cc3 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 1 Jul 2026 13:52:54 +0800 Subject: [PATCH] docs(examples): build and document graph.pb generation in infer_water The infer_water README instructed users to run cmake and make, but the resulting inference binaries load a frozen model graph.pb that is gitignored and never generated. The convert_model.c helper that creates it was neither built by CMakeLists.txt nor mentioned in the README, so following the documented steps produced binaries that failed at runtime. Add convert_model as a CMake target and document the full sequence: build, run ./convert_model to generate graph.pb from the bundled test model, then run the inference examples. The README makes clear that make only compiles the executables and that convert_model must be run from the example directory with a TensorFlow-enabled build. Fix #5693 --- examples/infer_water/CMakeLists.txt | 5 +++++ examples/infer_water/README.md | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/examples/infer_water/CMakeLists.txt b/examples/infer_water/CMakeLists.txt index c82816c912..bfa15e4a16 100644 --- a/examples/infer_water/CMakeLists.txt +++ b/examples/infer_water/CMakeLists.txt @@ -4,6 +4,11 @@ project(infer_water) # find DeePMD-kit find_package(DeePMD REQUIRED) +# helper that generates graph.pb from the bundled test model +add_executable(convert_model convert_model.c) +# link DeePMD-kit C API +target_link_libraries(convert_model PRIVATE DeePMD::deepmd_c) + # C++ example add_executable(infer_water_cc infer_water.cpp) # link DeePMD-kit C++ API diff --git a/examples/infer_water/README.md b/examples/infer_water/README.md index 290dd8cd1d..4008116251 100644 --- a/examples/infer_water/README.md +++ b/examples/infer_water/README.md @@ -8,3 +8,26 @@ Build the project using cmake -DCMAKE_PREFIX_PATH=$deepmd_root . make ``` + +Building only compiles the executables; it does not create the model file. +The inference programs load a frozen model `graph.pb` from the current +directory, so generate it first by running the `convert_model` helper, which +converts the bundled test model `../../source/tests/infer/deeppot.pbtxt` into +`graph.pb`: + +```sh +./convert_model +``` + +Run `convert_model` from this directory so the relative path to the bundled +model resolves. It requires `$deepmd_root` to be built with the TensorFlow +backend, because `graph.pb` is a TensorFlow frozen model. + +Then run any of the inference examples: + +```sh +./infer_water_cc +./infer_water_c +./infer_water_hpp +./infer_water_nlist +```