Skip to content

Instantly share code, notes, and snippets.

@fo40225
Last active January 29, 2018 11:58
Show Gist options
  • Save fo40225/b10b7233828af0ecfe09163a20487945 to your computer and use it in GitHub Desktop.
Save fo40225/b10b7233828af0ecfe09163a20487945 to your computer and use it in GitHub Desktop.
tensorflow 1.4.0 on windows with avx2 & cuda 9.1 & cudnn 7 by cmake
tensorflow 1.4.0 on windows with avx2 & cuda 9.1 & cudnn 7 by cmake
win 10 1703
git 2.14.1
cmake 3.9.6
anaconda3 5.0.0
cuda 9.1.85
cudnn 7.0.5 with cuda9.1
visual studio 2017 15.4 (msvc 1911)
# Note vs 15.5 (msvc 1912) didn't work with cuda 9.1.85
https://www.visualstudio.com/en-us/productinfo/installing-an-earlier-release-of-vs2017
https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
swigwin-3.0.10
git clone https://github.com/tensorflow/tensorflow.git -b v1.4.0
cd tensorflow/tensorflow/contrib/cmake
mkdir build
cd build
# edit tensorflow/workspace.bzl:187
https://github.com/tensorflow/tensorflow/commit/908343b5c0f957224ee44512d7ccfc81a8349e2f
# edit tensorflow\tensorflow\contrib\cmake\CMakeLists.txt
# change compute capabilities (1080ti)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_61,code=\"compute_61\")
add_definitions(-DGOOGLE_CUDA=1 -DTF_EXTRA_CUDA_CAPABILITIES=6.1)
"#define TF_CUDA_CAPABILITIES CudaVersion(\"6.1\")\n"
# change version
"#define TF_CUDA_VERSION \"64_91\"\n"
"#define TF_CUDNN_VERSION \"64_7\"\n"
cudart_dll_name=cudart64_91.dll
cuda_version_number=9.1
cudnn_dll_name=cudnn64_7.dll
cudnn_version_number=7)
cmake .. -G "Visual Studio 15 2017" -A x64 -T host=x64 ^
-DCMAKE_BUILD_TYPE=Release ^
-DSWIG_EXECUTABLE=C:\Users\User\swigwin-3.0.10\swig.exe ^
-DPYTHON_EXECUTABLE=C:\Users\User\Anaconda3\python.exe ^
-DPYTHON_LIBRARY=C:\Users\User\Anaconda3\libs\python36.lib ^
-Dtensorflow_ENABLE_GPU=ON ^
-DCUDA_HOST_COMPILER="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\Hostx64\x64" ^
-DCUDNN_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1" ^
-Dtensorflow_WIN_CPU_SIMD_OPTIONS="/arch:AVX2"
#cmake --build . --target tf_python_build_pip_package --config Release
#MSBuild /p:Configuration=Release tf_python_build_pip_package.vcxproj
devenv /UseEnv tensorflow.sln /Build Release /Project tf_python_build_pip_package.vcxproj /ProjectConfig Release
# build break fix
tensorflow\tensorflow\contrib\cmake\build\external\eigen_archive\Eigen\Core:59
#include <crt/math_functions.hpp>
tensorflow\tensorflow\contrib\cmake\build\external\eigen_archive\Eigen\src\Core\arch\CUDA\Half.h:158
return __hadd((__half)a, (__half)b);
# locale win fix
tensorflow\contrib\cmake\external\re2.cmake:47
-DRE2_BUILD_TESTING:BOOL=OFF
pip install tf_python\dist\tensorflow_gpu-1.4.0-cp36-cp36m-win_amd64.whl
# fix anaconda3 5.0.0 pip install broken after install tensorflow 1.4.0
Exception:
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\User\Anaconda3\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Users\User\Anaconda3\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "C:\Users\User\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
pip uninstall html5lib -y
conda uninstall html5lib --force -y
conda install html5lib==0.999999999 --no-deps -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment