tensorflow: Build tensorflow on windows with mkl fails
System information
- OS Platform: windows server 2012 R2 standard
- TensorFlow build from source:
- TensorFlow version: r1.13
- Python version: 3.6.7
- Bazel version: 0.21
- Compiler version (if compiling from source): 15.4
I’m trying build tf on windows with mkl running this command:
bazel build --config=opt --config=mkl //tensorflow/tools/pip_package:build_pip_package
build failed with this error:
INFO: From Executing genrule //tensorflow/python:pywrap_tensorflow_filtered_def_file:
symbols=108196, taken=36183, dupes=0
ERROR: C:/tfb/tensorflow/tensorflow/lite/toco/python/BUILD:44:1: Linking of rule '//tensorflow/lite/toco/python:_tensorflow_wrap_toco.so' failed (Exit 1000): link.exe failed: error executing command
cd C:/users/awaizman101364/_bazel_awaizman101364/5eebsbmp/execroot/org_tensorflow
SET LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x
64;
SET PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework64\;C:\Program Files (x86)\Windows Kits\
10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;;C:\Windows\system32
SET PWD=/proc/self/cwd
SET PYTHON_BIN_PATH=C:/Users/AWaizman101364/AppData/Local/Programs/Python/Python36/python.exe
SET PYTHON_LIB_PATH=C:/Users/AWaizman101364/AppData/Local/Programs/Python/Python36/lib/site-packages
SET TEMP=C:\Users\AWAIZM~1\AppData\Local\Temp\2
SET TF_DOWNLOAD_CLANG=0
SET TF_NEED_CUDA=0
SET TF_NEED_OPENCL_SYCL=0
SET TF_NEED_ROCM=0
SET TMP=C:\Users\AWAIZM~1\AppData\Local\Temp\2
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe /nologo /DLL /SUBSYSTEM:CONSOLE /MACHINE:X64 @bazel-out/x64_windows-opt/bin/tensorflow/lite/toco/python/_tensorflow_wrap_toc
o.so-2.params /OPT:ICF /OPT:REF
Execution platform: @bazel_tools//platforms:host_platform
LINK : warning LNK4044: unrecognized option '/ldl'; ignored
LINK : warning LNK4044: unrecognized option '/lpthread'; ignored
LINK : warning LNK4044: unrecognized option '/ldl'; ignored
bazel-out/x64_windows-opt/bin/external/com_google_absl/absl/numeric/int128.lib : fatal error LNK1000: Internal error during CImplib::EmitThunk
Version 14.00.24210.0
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 00007FF787836896 (00007FF787820000) "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe"
NumberParameters = 00000002
ExceptionInformation[ 0] = 0000000000000000
ExceptionInformation[ 1] = 0000000000000008
CONTEXT:
Rax = 0000000000000000 R8 = 00007FF78791FBE0
Rbx = 0000000000000000 R9 = 00007FF78791E9F0
Rcx = 0000000000000000 R10 = 0000000000000000
Rdx = 00007FF78791FBD8 R11 = 0000000000000000
Rsp = 00000084E2C2E1B8 R12 = 00007FF7878ED950
Rbp = 00000084E4E5D5A0 E13 = 0000000000000000
Rsi = 0000000000008000 R14 = 0000000000000000
Rdi = 00000084E57B2100 R15 = 0000000000000000
Rip = 00007FF787836896 EFlags = 0000000000010246
SegCs = 0000000000000033 SegDs = 000000000000002B
SegSs = 000000000000002B SegEs = 000000000000002B
SegFs = 0000000000000053 SegGs = 000000000000002B
Dr0 = 0000000000000000 Dr3 = 0000000000000000
Dr1 = 0000000000000000 Dr6 = 0000000000000000
Dr2 = 0000000000000000 Dr7 = 0000000000000000
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 606.229s, Critical Path: 369.31s
INFO: 4122 processes: 4122 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
Is there a way to build tf with mkl on windows?
Thanks.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17
I got it working by putting
libiomp5md.dll
andmklml.dll
on thePATH
before starting the build of the source modified with the following patch:What this does is “trick” Bazel into not using
/WHOLEARCHIVE
on them, which is apparently the cause of the problem. This is what has already been done to make CUDA work on Windows: https://github.com/tensorflow/tensorflow/blob/master/third_party/gpus/cuda/BUILD.windows.tpl#L57The linker issue appears when /WHOLEARCHIVE switch is used along with link.exe on windows when using Visual Studio 2015. Alternatively, you can install the hotfix available at https://support.microsoft.com/en-us/help/4020481/fix-link-exe-crashes-with-a-fatal-lnk1000-error-when-you-use-wholearch to overcome this issue.
D:\CodeSofteware\tensorflow-r1.13\bazel-bin\external\protobuf_archive\protoc_lib.lib : fatal error LNK1000: Internal error during CImplib::EmitThunk Version 14.00.24215.1 ExceptionCode = C0000005 ExceptionFlags = 00000000 ExceptionAddress = 00ACD798 (00AB0000) “D:\CodeSofteware\VisualStudio2015\VC\bin\x86_amd64\link.exe” NumberParameters = 00000002 ExceptionInformation[ 0] = 00000000 ExceptionInformation[ 1] = 00000004 CONTEXT: Eax = 000DDEEE Esp = 00EFE62C Ebx = 00B82E44 Ebp = 00EFE630 Ecx = 00000000 Esi = 00000000 Edx = 00B83C68 Edi = 00000000 Eip = 00ACD798 EFlags = 00010296 SegCs = 00000023 SegDs = 0000002B SegSs = 0000002B SegEs = 0000002B SegFs = 00000053 SegGs = 0000002B Dr0 = 00000000 Dr3 = 00000000 Dr1 = 00000000 Dr6 = 00000000 Dr2 = 00000000 Dr7 = 00000000 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I got this error too, when using C++ API builed by bazel0.21.0 any one solved it?? Tell me and thanks!
Right now, the only build that’s available for windows is in Anaconda’s main channel. We are working on the feature to distribute pip wheels which will be made available shortly. In the meantime, we are investigating the linker issue to be able to provide an alternative solution to compile. QQ, Did you have to use the workaround provided to compile for 1.10 in cmake?
@awaizman1 we are investigating the issue. But if you would like to get the installer without having to build one there is a conda package available on Anaconda. “conda install tensorflow-mkl” is the command