3 Star 7 Fork 3

learning-ml / hello_tf_c_api

加入 Gitee
与超过 800 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

Example TensorFlow C API

Example TensorFlow C API logo

Branch Linux/OSX Windows License Codacy
master Build Status Build status License Codacy Badge

Example how to run TensorFlow lib C API on Windows, Linux and macOS(Darwin).

Example

Build example

Windows

git clone --depth 1 https://github.com/Neargye/hello_tf_c_api
cd hello_tf_c_api
mkdir build
cd build
cmake -G "Visual Studio 15 2017" -A x64 ..
cmake --build . --config Debug

Linux and macOS(Darwin)

git clone --depth 1 https://github.com/Neargye/hello_tf_c_api
cd hello_tf_c_api
mkdir build
cd build
cmake -G "Unix Makefiles" ..
cmake --build .

Remarks

  • After the build, you can find the TensorFlow lib in the folder hello_tf_c_api/tensorflow/lib, and header in hello_tf_c_api/tensorflow/include.
  • The tensorflow in the repository is compiled in x64 mode. Make sure that project target 64-bit platforms.
  • Make sure that the tensorflow lib is in Output Directory or either in the directory contained by the %PATH% environment variable.

Get tensorflow lib

For x64 CPU, you can download the tensorflow.so, tensorflow.dll and tensorflow.lib from https://github.com/neargye-forks/tensorflow/releases.

Or build lib which version you need from the sources, with CPU or GPU support.

Link tensorflow lib

CMakeLists.txt

link_directories(yourpath/to/tensorflow) # path to tensorflow lib
... # other
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> tensorflow)

Visual Studio

"Project"->"Properties"->Configuration Properties"->"Linker"->"Additional Dependencies" and add path to your tensorflow.lib as a next line.

Make sure that the tensorflow.dll is in Output Directory (by default, this is Debug\Release under your project's folder) or either in the directory contained by the %PATH% environment variable.

Here’s an example how prepare models

To generated the graph.pb file need takes a graph definition and a set of checkpoints and freezes them together into a single file.

Here’s an example how create tensorflow.lib file from tensorflow.dll for windows

Licensed under the MIT License

仓库评论 ( 0 )

你可以在登录后,发表评论

简介

Tensorflow C API的调用示例 展开 收起
C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/learning-ml/hello_tf_c_api.git
git@gitee.com:learning-ml/hello_tf_c_api.git
learning-ml
hello_tf_c_api
hello_tf_c_api
master

搜索帮助

103111 552b83b3 1850385 103110 ed87a847 1850385