joe-antognini / joe-antognini.github.io

https://joe-antognini.github.io
MIT License
3 stars 1 forks source link

machine-learning/build-windows-tf #8

Closed joe-antognini closed 1 year ago

joe-antognini commented 1 year ago

Written on 06/22/2017 00:36:35

URL: https://joe-antognini.github.io/machine-learning/build-windows-tf

joe-antognini commented 1 year ago

Comment written by Abhimitra Meka on 10/26/2017 20:59:52

I had to make some modifications for this to work. My config is slightly different, Windows 7 and Visual Studio 2017. When I build tensorflow.sln with the above-mentioned steps, I get the error - "fatal error C1002: compiler is out of heap space in pass 2". To resolve this, after opening tensorflow.sln in VS2017, right click the project 'tf_core_kernels.vcxproj', open the properties, go to the VC++ directories and in the "Executable Directories" field, modify $(VC_ExecutablePath_x64) to $(VC_ExecutablePath_x64_x64).

This solved the problem for me. Credit to this link -> https://software.intel.com/...

Also, what is not mentioned here is that if you want to build with GPU support, you should
include -Dtensorflow_ENABLE_GPU=ON -DCUDNN_HOME="D:\...\cudnn" in your cmake command. This would require you to download cuDnn and unzip it somewhere and give the address to it in -DCUDNN_HOME.

joe-antognini commented 1 year ago

Comment written by Abhimitra Meka on 10/28/2017 17:49:35

Also want to mention, I could get the GPU version to build only on windows 10 and VS 2015 (which is the currently known "good configuration"), not on windows 7 or VS 2017. Do leave a comment here if you managed to build the GPU enabled version on windows 7, mentioning the steps you followed. It might help a lot of people out there.

joe-antognini commented 1 year ago

Comment written by Tian Jing on 11/07/2017 20:37:06

Thank you so much for the post. I got the error Fatal Error C1060 “compiler is out of heap space”. Could you describe in more details how to increase the memory of the virtual machine?

Thank you so much

joe-antognini commented 1 year ago

Comment written by Brian Cook on 11/21/2017 23:21:36

Using Visual Studio 2015, I also had the C1060 Compiler is out of heap space error, even though I had more than enough memory in my virtual machine. The problem was that the Visual Studio IDE runs with a 32-bit compiler even though it is generating a 64-bit project.

What worked for me was very simple. Just open a 64-bit developer command prompt under your Visual Studio folder named "VS2015 x64 Native Tools Command Prompt".

Then go to your solution folder and run this from the command line:

msbuild.exe tensorflow.sln /t:Build /p:Configuration=Release;Platform=x64

After a lot of frustration with the IDE, this worked with no problems at all.

joe-antognini commented 1 year ago

Comment written by Arnaldo Gualberto on 11/26/2017 10:51:03

Hi, guys
Does someone could build tensorflow for Windows using /MT option?
I’m stuck on that and I need some help, please.

Thanks

joe-antognini commented 1 year ago

Comment written by Manuel Cuevas on 11/30/2017 22:42:28

@Abh@abhimitrameka:disqus I builded tensorflow with GPU support just as you said, when I run my model in VS2015 i get LNK2001 errors. What Additional Dependecies did you add?

joe-antognini commented 1 year ago

Comment written by hornet bee on 12/01/2017 03:02:22

The errors from LNK2001 should give hint what is required cuda libraries needed

joe-antognini commented 1 year ago

Comment written by Mads Kehlet Jepsen on 12/01/2017 07:41:20

Thanks for the post. The current Master does not compile, but r1.4 worked for me. I found an other post where they recomended using the following msbuild line
msbuild /m:4 /p:CL_MPCount=1 /p:Configuration=Release /p:Platform=x64 /p:PreferredToolArchitecture=x64 ALL_BUILD.vcxproj

I got the x64 build environment using the windows key and searching for x64.

joe-antognini commented 1 year ago

Comment written by flow on 01/08/2018 15:33:50

Did you guys even research before posting?
If you get heap errors then compile the source files on your own. Just select like 10-20 files in a sequence and compile those. After all it's a mistake from the build system to let the compiler eat that much RAM.
There are some other problems which you can face. (CUDA Version + CUDA host compiler, path problems, non msvc/gcc compiler related errors)
Debug build works just fine but you will have to do some changes.

joe-antognini commented 1 year ago

Comment written by CPenet on 01/29/2018 15:47:39

Hello,
Thank you for all your advice, my compilation for CPU only is perfectly correct.
But I need the GPU version and I get an error from MSBUILD :
the compilation of tf_core_gpu_kernels.vcxproj is a failure.

I used these CMmake options :
-DCUDA_TOOLKIT_ROOT_DIR ="......./CUDA/v9.1"
-Dtensorflow_ENABLE_GPU=ON
-DCUDNN_HOME="..../cuDNN_7/cuda"

And I defined the path for Cuda and CudaNN.

Any clue?

joe-antognini commented 1 year ago

Comment written by CPenet on 02/01/2018 10:11:59

It was a problem with VS2017 : everything is better with VS2015!!!

joe-antognini commented 1 year ago

Comment written by Benedict Hartmann on 02/02/2018 09:53:06

And how did you do that?
Manually compiled it?

The main problem for me was at tf_core_kernels.vcxproj within generalblockkernelpanel.h

joe-antognini commented 1 year ago

Comment written by Renato Aloi on 04/15/2018 04:04:03

I built the static library today. Took me 2 days to figure out the necessary stuff to do it. I am going to share with you what worked for me.

1. Download and install Python version 3.5 https://www.python.org/down...

2. Use pip to install NumPy. Type the following command:
pip install numpy

3. Use the following cmake parameters:
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=C:\Path\to\swigwin-3.0.12\swig.exe -DPYTHON_EXECUTABLE=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python35\python.exe -DPYTHON_LIBRARIES=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python35\libs\python35.lib -DPYTHON_INCLUDE_DIR=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python35\include -DNUMPY_INCLUDE_DIR=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python35\Lib\site-packages\numpy\core\include

4. The last one is the most important parameter because you will only find out if you did it right after 2 or more hours of msbuild running. If you installed Python using default configuration, you will only need to set swig path. Leave the other parameters alone.

5. Even with you are going to build de solution by msbuild command, open the tensorflow.sln in Visual Studio 2015 first. It will check and resolve dependencies you are not aware about (yet).

6. Type and execute the following command:
msbuild /m:4 /p:CL_MPCount=1 /p:Configuration=Release /p:Platform=x64 /p:PreferredToolArchitecture=x64 ALL_BUILD.vcxproj

7. Sit back and enjoy 2 or more hours of compilling. My notebook done it in 5 hours!

I hope these instructions above spare you from 2 days banging the head against the wall.

joe-antognini commented 1 year ago

Comment written by Yuhwan on 04/23/2018 13:16:19

Hi i got some error like " [libprotobuf FATAL ..\..\common.cc] This program was compiled against version 3.4.0 of the Protocol Buffer runtime library, which is not compatible with the installed version <3.5.0> Contact the program author for an update"

How can i do...? anyway I'm using window 7 , is error caused because of window 7 ?

joe-antognini commented 1 year ago

Comment written by Renato Aloi on 04/24/2018 14:52:58

Hi Yuhwan! Try uninstall protobuf and reinstall it. Try this out:
> pip uninstall protobuf
> pip install protobuf

joe-antognini commented 1 year ago

Comment written by Stephan Yhann on 04/27/2018 17:20:32

The easiest way I found is to set the following system environment variable on windows:
PreferredToolArchitecture=x64

This sets it globally for Visual Studio.

You can also set it on the command line and launch DevEnv from that shell.

joe-antognini commented 1 year ago

Comment written by Xián López Álvarez on 05/04/2018 08:22:55

After much fighting, I managed to compile it. I'm using Windows 10 and Visual Studio 2015 (I tried with 2017 but was unable). I compiled TensorFlow r1.5, using CUDA 9 and cuDNN 7. It took 2h 41'. I think it was important for me to use Anaconda3 python, instead of another distribution. I used Anaconda 4.1.1 64-bits.

First of all, I made sure to have in my Path the paths to ...Anaconda3, ...Anaconda3\Scripts, ...Anaconda3\Library\bin, ...\CUDA\v9.0\bin, ...\CUDA\v9.0\libnvvp, as well as the folder with cuDNN.

Then opened VS2015 x64 Native Tools Command Promt, run vcvars64.bat, go to ...\cmake\build, and run the following:
cmake .. -G "Visual Studio 14" -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=C:\swigwin-3.0.12\swig.exe -DPYTHON_EXECUTABLE=C:\Users\xlopez\Anaconda3\python.exe -DPYTHON_LIBRARIES=C:\Users\xlopez\Anaconda3\libs\python35.lib -Dtensorflow_ENABLE_GPU=ON -DCUDNN_HOME="C:\cuda9_cudnn7"

Then msbuild.exe tensorflow.sln /t:Build /p:Configuration=Release;Platform=x64
I hope this helps, because it can be a real pain to make this work.

joe-antognini commented 1 year ago

Comment written by shiva prasad on 05/14/2019 12:07:17

Hi,, I am following the above mentioned steps. But i am facing error while building. Can you please help.

ERROR:

-- Found PythonLibs: C:/Users/shiva/AppData/Local/Programs/Python/Python35/libs/python35.lib (found version "3.5.2")
CMake Error at tf_python.cmake:217 (message):
Python module not found: tensorflow/contrib/tpu/ops
Call Stack (most recent call first):
CMakeLists.txt:612 (include)

joe-antognini commented 1 year ago

Comment written by Adrian Stokes on 12/21/2021 16:01:23

just tried to install this for visual studio 2022 getting following error

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.30.30706.0
-- The CXX compiler identification is MSVC 19.30.30706.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at external/eigen.cmake:11 (file):
file STRINGS file
"C:/Users/kerra/tensorflow/tensorflow/contrib/cmake/../../workspace.bzl"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:78 (include)

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/ExternalProject.cmake:2781 (message):
URL_HASH is set to

SHA256=

but must be ALGO=value where ALGO is

MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512

and value is a hex string.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.22/Modules/ExternalProject.cmake:3716 (_ep_add_download_command)
external/eigen.cmake:37 (ExternalProject_Add)
CMakeLists.txt:78 (include)

-- Configuring incomplete, errors occurred!
See also "C:/Users/kerra/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeOutput.log".

C:\Users\kerra\tensorflow\tensorflow\contrib\cmake\build>