https://github.com/loseall/tensorflow-cmake
tensorflow build by CMake
https://github.com/loseall/tensorflow-cmake
cmake tensorflow windows
Last synced: about 1 year ago
JSON representation
tensorflow build by CMake
- Host: GitHub
- URL: https://github.com/loseall/tensorflow-cmake
- Owner: LoSealL
- License: apache-2.0
- Created: 2018-08-20T13:26:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-07T02:04:24.000Z (over 7 years ago)
- Last Synced: 2025-03-25T13:11:17.865Z (over 1 year ago)
- Topics: cmake, tensorflow, windows
- Language: C++
- Size: 27.5 MB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
- Authors: AUTHORS
Awesome Lists containing this project
README
### NOTICE
The original tensorflow [readme](./README_TF.md).
### TensorFlow CMake for Windows
Because beyond tensorflow `r1.11`, tensorflow officially drop CMake build files, and support only bazel, so I personally try to maintain a cmake build scripts for tensorflow.
### Environment
The following lists prerequisite softwares and libraries:
- [python3](https://www.python.org/) (v3.6 in *Anaconda* is recommended)
- [cmake](https://cmake.org/download/) >= 3.12
- [git](https://git-scm.com/download/win)
- cuda == 9.0
- cudnn == 7.0
The following lists prerequisite pip packages:
- absl-py >= 0.2.2
- protobuf >= 3.6.0
- numpy**
- six
- setuptools
- wheel
Compilers (tested by me):
- VS 2015 (vc14), or
- VS 2017 (vc15)***
*Swig is pre-downloaded into `./_build`
**You should the same version of numpy in __BUILD__ and __USE__
***When you use the newest VS 2017, CUDA compile check may fail, to resolve this, see [here](https://github.com/LoSealL/tensorflow-cmake/wiki/Resolve-CUDA-compile-check-error-in-CMAKE)
### How to compile
Start into VS x64 prompt.
====================
```bash
> mkdir _build && cd _build
> cmake .. -A x64 -T host=x64 ^
-DCMAKE_BUILD_TYPE=Release ^
-DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% ^
-DPYTHON_LIBRARIES=%PYTHON_LIB% ^
-Dtensorflow_ENABLE_GPU= ^
-Dtensorflow_BUILD_SHARED_LIB= ^
-Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX2 ^
-Dtensorflow_ENABLE_MKL_SUPPORT= ^
-Dtensorflow_ENABLE_MKLDNN_SUPPORT= ^
-Dtensorflow_BUILD_PYTHON_BINDINGS= ^
-Dtensorflow_DISABLE_EIGEN_FORCEINLINE= ^
-Dtensorflow_ENABLE_GRPC_SUPPORT=ON ^
-Dtensorflow_ENABLE_SSL_SUPPORT= ^
-Dtensorflow_ENABLE_SNAPPY_SUPPORT=
> cmake --build . --config Release --target tf_python_build_pip_package
```
Note: `^` is another line, GRPC must set `ON`, `WIN_CPU_SIMD_OPTIONS` can set to `OFF` if you don't know what's AVX. `PYTHON_EXECUTABLE` and `PYTHON_LIB` should specify to your own path.(Path to python.exe and python36.lib for instance)
OR your can try experimentally script `make.bat` to auto search required path
```bash
> make && cd _build
> cmake --build . --config Release --target tf_python_build_pip_package
```
Before doing this, your must edit `make.bat` and your own options (such as GPU or MKL)
### File Re-organized
The original cmake files are all in the `./tensorflow/contrib/cmake`, it's better to add `CMakeLists.txt` to each sub-folders
-----
THANKS TO ALL THE CONTRIBUTORS TO CMAKE SCRIPTS