A highly experimental TensorFlow plugin for TouchDesigner.
This will be updated.
- Clone this repository.
- Create a folder inside called
libs
. - Clone the TensorFlow repository inside of
libs
. - Follow the instructions below to build TensorFlow.
- Install
Visual Studio 2015
. - Install
CUDA 8.0
andcuDNN 5.1
. - Install
Anaconda
for Windows. - Run
conda install python=3.5
to install the proper version of Python (you can verify that the correct version of Python is installed by opening a newcmd
prompt and running the commandpython
: you should see text likePython 3.5.4 ...
before the interpreter is launched). - Install
SWIG
(latest.exe
for Windows x64). - Add the
SWIG
folder location to yourPATH
, as it is referenced during the build. - Navigative to
libs\tensorflow\tensorflow\contrib\cmake\
. - Create a folder here called
build
. - Navigative inside this folder.
- Run the command:
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release
: this will generate aVisual Studio 2015
solution file calledtensorflow.sln
. - Open this file in
Visual Studio 2015
. - By default, the project named
ALL_BUILD
will be selected. - Make sure that your configuration is set to
Release
andx64
. - Right-click
ALL_BUILD
in the solution explorer and clickbuild
. - Wait about 2 hours...
- Finally, if the build succeeds, create an environment variable
$TENSORFLOW_BUILD
pointing to thebuild
directory.
- Create a new
Visual Studio 2015
project. - Add a new file named
main.cpp
. - Under
C/C++ -> General -> Additional Include Directories
, add:
$(TENSORFLOW_BUILD);
$(TENSORFLOW_BUILD)\..\..\..\..\;
$(TENSORFLOW_BUILD)\..\..\..\..\third_party\eigen3;
$(TENSORFLOW_BUILD)\external\zlib_archive;
$(TENSORFLOW_BUILD)\external\gif_archive\giflib-5.1.4;
$(TENSORFLOW_BUILD)\external\png_archive;
$(TENSORFLOW_BUILD)\external\jpeg_archive;
$(TENSORFLOW_BUILD)\external\lmdb;
$(TENSORFLOW_BUILD)\external\eigen_archive;
$(TENSORFLOW_BUILD)\gemmlowp\src\gemmlowp;
$(TENSORFLOW_BUILD)\jsoncpp\src\jsoncpp;
$(TENSORFLOW_BUILD)\external\farmhash_archive;
$(TENSORFLOW_BUILD)\external\farmhash_archive\util;
$(TENSORFLOW_BUILD)\external\highwayhash;
$(TENSORFLOW_BUILD)\cub\src\cub;
$(TENSORFLOW_BUILD)\external\nsync\public;
$(TENSORFLOW_BUILD)\protobuf\src\protobuf\src;
$(TENSORFLOW_BUILD)\re2\install\include;
$(TENSORFLOW_BUILD)\external\sqlite;
$(TENSORFLOW_BUILD)\grpc\src\grpc\include;
$(TENSORFLOW_BUILD)\snappy\src\snappy;
- Under
C/C++ -> Preprocessor -> Preprocessor Definitions
, add:
COMPILER_MSVC;
PLATFORM_WINDOWS;
- Under
Linker -> General -> Additional Library Directories
, add$(TENSORFLOW_BUILD)
. - Under
Linker -> Input -> Additional Dependencies
, add the following libraries:
re2\src\re2\$(Configuration)\re2.lib;
grpc\src\grpc\Release\grpc++_unsecure.lib;
grpc\src\grpc\Release\grpc_unsecure.lib;
grpc\src\grpc\Release\gpr.lib;
zlib\install\lib\zlibstatic.lib;
gif\install\lib\giflib.lib;
png\install\lib\libpng12_static.lib;
jpeg\install\lib\libjpeg.lib;
lmdb\install\lib\lmdb.lib;
jsoncpp\src\jsoncpp\src\lib_json\$(Configuration)\jsoncpp.lib;
farmhash\install\lib\farmhash.lib;
fft2d\src\lib\fft2d.lib;
highwayhash\install\lib\highwayhash.lib;
nsync\install\lib\nsync.lib;
snappy\src\snappy\Release\snappy.lib;
protobuf\src\protobuf\Release\libprotobuf.lib;
tf_cc.dir\Release\tf_cc.lib;
tf_cc_ops.dir\Release\tf_cc_ops.lib;
tf_cc_framework.dir\Release\tf_cc_framework.lib;
tf_core_cpu.dir\Release\tf_core_cpu.lib;
tf_core_direct_session.dir\Release\tf_core_direct_session.lib;
tf_core_framework.dir\Release\tf_core_framework.lib;
tf_core_kernels.dir\Release\tf_core_kernels.lib;
tf_core_lib.dir\Release\tf_core_lib.lib;
tf_core_ops.dir\Release\tf_core_ops.lib;
tf_cc_while_loop.dir\Release\tf_cc_while_loop.lib;
Release\tf_protos_cc.lib;
sqlite\install\lib\sqlite.lib
which are all relative to the $(TENSORFLOW_BUILD)
path.
6. Under Linker -> Command Line -> Additional Options
, add:
/machine:x64
/ignore:4049
/ignore:4197
/ignore:4217
/ignore:4221
/WHOLEARCHIVE:tf_cc.lib
/WHOLEARCHIVE:tf_cc_framework.lib
/WHOLEARCHIVE:tf_cc_ops.lib
/WHOLEARCHIVE:tf_core_cpu.lib
/WHOLEARCHIVE:tf_core_direct_session.lib
/WHOLEARCHIVE:tf_core_framework.lib
/WHOLEARCHIVE:tf_core_kernels.lib
/WHOLEARCHIVE:tf_core_lib.lib
/WHOLEARCHIVE:tf_core_ops.lib
/WHOLEARCHIVE:libjpeg.lib
to the text field
7. Back in main.cpp
, add the following include
directives:
#include "tensorflow/cc/ops/const_op.h"
#include "tensorflow/cc/ops/image_ops.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/graph/default_device.h"
#include "tensorflow/core/graph/graph_def_builder.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/core/threadpool.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/util/command_line_flags.h"
- Generate the model with
export_model.py
.
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/cmake/README.md
https://joe-antognini.github.io/machine-learning/build-windows-tf
http://anonimousindonesian.blogspot.com/2017/12/tutorial-how-to-build-tensorflow.html
https://github.com/jhjin/tensorflow-cpp
https://gist.github.com/kyrs/9adf86366e9e4f04addb