tensorflow-windows-build-script
tensorflow-windows-build-script copied to clipboard
Can you give me a sample code for C++
I want to load a model written in Python and run it in C ++, So I built tensorflow to this script, like below
\test\tensorflow-windows-build-script\tensorflow-windows-build-script> $parameterString = "--config=opt --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures"
.\build.ps1
-BazelBuildParameters $parameterString
-BuildCppAPISelect a Tensorflow version: [1] 1 - v1.13.1 [2] 2 - v1.12.0 [3] 3 - v1.11.0 [S] Select another version [?] 도움말 (기본값은 "1"): 1 Found chocolatey installed. Unable to find pacman. Which version would you like to install? [Default version: 20180531.0.0]: Chocolatey v0.10.15 Installing the following packages: msys2 By installing you accept licenses for the packages. msys2 v20180531.0.0 already installed. Use --force to reinstall, specify a version to install, or try upgrade.
Chocolatey installed 0/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Warnings:
- msys2 - msys2 v20180531.0.0 already installed. Use --force to reinstall, specify a version to install, or try upgrade. Found patch installed. Found unzip installed. Found bazel installed. Make sure you have installed same version of bazel 0.20.0. Are you sure you want to PROCEED? [y/n]: y Found git installed. Found python installed. Make sure you have installed same version of python 3.6.7. Are you sure you want to PROCEED? [y/n]: y Cloning into 'tensorflow'... . . .
You have bazel 0.20.0 installed. Do you wish to build TensorFlow with XLA JIT support? [y/N]: N No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with ROCm support? [y/N]: N No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: Y CUDA support will be enabled for TensorFlow.
Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: 10.0
Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0]:
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.6.0
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0]:
Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,7.0]: 7.5
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]:
Would you like to override eigen strong inline for some C++ compilation to reduce the compilation time? [Y/n]: Y
and I built Successful like this
Target //tensorflow:libtensorflow_cc.so up-to-date: C:/users/dms-sub/_bazel_dms-sub/ny34nikw/execroot/org_tensorflow/bazel-out/x64_windows-opt/bin/tensorflow/libtensorflow_cc.so INFO: Elapsed time: 2541.753s, Critical Path: 721.17s INFO: 3585 processes: 3585 local. INFO: Build completed successfully, 4583 total actions WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files: c:\users\dms-sub\downloads\test\tensorflow-windows-build-script\tensorflow-windows-build-script-master\source/.bazelrc INFO: Invocation ID: 1e591d52-f6b5-4042-8c4a-397596b33cc0
and I extract C++library, use wiki
See this gist which extracts the Tensorflow library. Then set Visual Studio to link and compile with these files.
And the third-party sources are in $sourceDir\bazel-source\external. Now there is no way to link the built third-party libraries.
I do not understand this sentence.
And the third-party sources are in $sourceDir\bazel-source\external. Now there is no way to link the built third-party libraries.
Please explain this again...
I then linked the libraries to VS2017 and ran the sample code below.
#include "tensorflow/core/public/session.h"
int main() {
return 0;
}
But I got a lot of build errors (some headers, no pd files)...
It means you need to include all sources of either Tensorflow or third-party ones into VS's included directories.