Building Tensorflow on Windows is really a tough thing and there should be many problems to solve. Thus, this script automates the process of building on Windows, which does the following things for you:
This script has been tested on v1.13.1
, v1.12.0
and v1.11.0
.
However, this script may work on several unsupported versions. If you did this and succeeded, it would be nice of you to add your configurations to the script by pull requests! Through Bulletin Board
You may need to do some preparations below:
v1.11.0
, v1.12.0
and v1.13.1
, you should add symbols that you need into patches\tf_exported_symbols_msvc.lds
. If you don't know what symbols you need, never mind and skip this step. When you use the built C++ API, the linker will probably give you link errors, telling what symbols you need.Run the script in the repository directory with administrator rights.
.\build.ps1 -BazelBuildParameters <parameter_string> [optional_parameters]
When you encounter Make sure you have installed same version of $ExeName $RequiredVersion
, make sure you have installed same version of what we recommend, otherwise we advise you to uninstall your installed ones and re-run the script which will automatically install recommended ones. Or you can proceed with high possibility to get stuck in problems. After having cleared the version issues, you must be glad to add -IgnoreDepsVersionIssues
flag next time.
Considering that not every installed software is installed by chocolatey, we cannot automate the uninstallation process for you. On the other hand, if some of your installed ones are indeed choco packages, please view chocolatey docs to uninstall them manually.
source\bazel-bin
folder. View wiki to find some advice on how to use the built results.-BazelBuildParameters <string>
Mandatory
A string which is passed to Bazel to build Tensorflow.
If you want to build a PyPI wheel, you need //tensorflow/tools/pip_package:build_pip_package
.
If you want to build a C API, you need //tensorflow:libtensorflow.so
.
If you want to build a C++ API, you need //tensorflow:libtensorflow_cc.so
.
For more information, click here.
-BuildCppAPI
Optional
This is needed when buiding C++ API of v1.11.0
, v1.12.0
and v1.13.1
.
-ReserveSource
Optional
Denote it when you confirm that you have a valid tensorflow repository in source
folder and do not want to re-clone it in the next building.
-ReserveVenv
Optional
Denote it when you confirm that you have a valid virtual environment in venv
folder and do not recreate one.
-IgnoreDepsVersionIssues
Optional
Denote it to ignore the warnings due to different versions of dependencies you have installed.
-InstallDefaultDeps
Optional
Install default version of dependencies if not installed.
# It is an example for building C++ API with GPU support.
$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 `
-BuildCppAPI -ReserveSource -ReserveVenv
subprocess.CalledProcessError
.