tensorflow-windows-wheel icon indicating copy to clipboard operation
tensorflow-windows-wheel copied to clipboard

Any hope for C++ builds again?

Open juliandewit opened this issue 5 years ago • 12 comments

Hello thanks for all your effort. I know in the latest versions you could not make a C++ GPU version of the dll.

This blocks me effectively from building applications for 20XX cards. So you can imagine I'm getting a bit desperate.

Is it hopelessly impossible to make a C++ version ? If not I would be willing to donate to you.

juliandewit avatar Mar 06 '19 12:03 juliandewit

https://github.com/tensorflow/tensorflow/commit/0c8deb2f9178feef562320688198885b23ffd647

Tensorflow 2.0 seems fix the windows c++ dll build issue.

You can try it.

I will upload c++ lib if tf 2.0 really support build c++ dll on windows.

fo40225 avatar Mar 23 '19 04:03 fo40225

Thanks for the info.

juliandewit avatar Apr 12 '19 07:04 juliandewit

@fo40225 Does that mean we can't build c++ dll on windows using tensorflow version which higher than 1.10.0 ? And may I ask whether you use bazel or cmake to make it happen?

ofexe avatar May 20 '19 09:05 ofexe

@ofexe tf 1.8.0 is the latest version that can build cpp lib with cmake.

1.9.0 & 1.10.0 need some fix to make cmake cpp lib build script work.

after 1.11.0, tf deprecated cmake and use bazel to build.

bazel didn't support build the cpp lib on windows until now (1.13.1)

You can try to use cmake to build cpp lib on newer tf.

fo40225 avatar May 21 '19 04:05 fo40225

For anyone interested in compiling v 1.13.1 cpp I used the script from https://github.com/guikarist/tensorflow-windows-build-script, modifying it a bit for my use case. My configuration was

Bazel 0.19.2
Visual Studio 2015
Cuda 9.2
cuDnn 7

enabling avx2 instructions. The compilation took ~2h. The main problem was that at end the symbols I needed were not exported, but if you add them to the proper file it´s just a matter of minutes to rerun the linking part.

lorenzolightsgdwarf avatar May 23 '19 11:05 lorenzolightsgdwarf

@fo40225

1.9.0 & 1.10.0 need some fix to make cmake cpp lib build script work.

could you introduce that how to fix the cmake for tf1.9 and 1.10 ? i need tf1.10 cpp lib for vs2015, but the version you provide tf1.10 is vs2017

southrough avatar Jun 14 '19 03:06 southrough

@southrough

https://github.com/tensorflow/tensorflow/pull/19415/files

check create_def_file.py it should export the symbol you need

fo40225 avatar Jun 14 '19 03:06 fo40225

@fo40225

https://github.com/tensorflow/tensorflow/pull/19415/files

check create_def_file.py it should export the symbol you need

so what should i do is to change the file back? to make the py file like that in tf 1.8?

southrough avatar Jun 14 '19 05:06 southrough

@fo40225 i have checked create_def_file.py. in fact, the source file of tf1.10 has been fixed by the way of https://github.com/tensorflow/tensorflow/pull/19415/files when i download it. now the problem i faced is that

error LNK2001:无法解析的外部符号 "private: void __cdecl tensorflow::GraphDef::InternalSwap(class tensorflow::GraphDef *)" (?InternalSwap@GraphDef@tensorflow@@AEAAXPEAV12@@Z)

it has been mentionned in question https://github.com/fo40225/tensorflow-windows-wheel/issues/30, i want to know whether there are some ideas to deal with it. i try to feed back the fixed in https://github.com/tensorflow/tensorflow/pull/19415/files, but it doesn't works.

southrough avatar Jun 17 '19 02:06 southrough

@southrough

The change in the https://github.com/tensorflow/tensorflow/pull/19415 will filter out some c++ symbol.

You need to revert the exclude/include rule and fix the rule to prevent the limit of single lib can only have 65536 symbol in msvc.

Once you fix the create_def_file.py, you can use cmake to build c++ lib.

fo40225 avatar Jun 17 '19 03:06 fo40225

@fo40225 ok, i will try to revert the fix in tensorflow/tensorflow#19415, and use cmake to build C++ lib again. thanks for your reply.

southrough avatar Jun 17 '19 03:06 southrough

@fo40225 thanks to your advices i fix the create_def_file.py, include InternalSwap to symbol i add r"tensorflow::GraphDef::InternalSwap|" in INCLUDEPRE_RE

error LNK2001:无法解析的外部符号 "private: void __cdecl tensorflow::GraphDef::InternalSwap(class tensorflow::GraphDef *)" (?InternalSwap@GraphDef@tensorflow@@AEAAXPEAV12@@z)

this issue have been solved, and tf1.10 c++lib can be used. thanks for your help.

southrough avatar Jun 18 '19 01:06 southrough