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 +```