網頁

2018年12月7日 星期五

build tensorflow 1.10

參考 build tensorflow 1.11 from source in visual studio

(base) D:\TensorFlowB>conda env list
(base) D:\TensorFlowB>conda env remove -n tensorflow-1.10
(base) D:\TensorFlowB>conda create -n tensorflow-1.10 pip python=3.6
(base) D:\TensorFlowB>activate tensorflow-1.10
(tensorflow-1.10) D:\TensorFlowB>pip install six numpy wheel protobuf absl-py
(tensorflow-1.10) D:\TensorFlowB>pip install keras_applications==1.0.5 --no-deps
(tensorflow-1.10) D:\TensorFlowB>pip install keras_preprocessing==1.0.3 --no-deps

D:\TensorFlowB>git clone https://github.com/tensorflow/tensorflow.git tensorflow-1.10
D:\TensorFlowB>cd tensorflow-1.10
D:\TensorFlowB\tensorflow-1.10>git checkout r1.10
D:\TensorFlowB\tensorflow-1.10>git pull origin master
D:\TensorFlowB\tensorflow-1.10>bazel clean
D:\TensorFlowB\tensorflow-1.10>python ./configure.py

修改 D:/TensorFlowB/tensorflow-1.10/tensorflow/contrib/cmake/CMakeLists.txt

if (tensorflow_OPTIMIZE_FOR_NATIVE_ARCH)
  include(CheckCXXCompilerFlag)
  CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
  if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
  else()
    CHECK_CXX_COMPILER_FLAG("/arch:AVX2" COMPILER_OPT_ARCH_AVX_SUPPORTED)
    if(COMPILER_OPT_ARCH_AVX_SUPPORTED)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
      add_definitions(-D__AVX2__)
    endif()
  endif()
endif()

D:/TensorFlowB/tensorflow-1.10/tensorflow/contrib/cmake
選 Visual Studio 14 2015 Win64
Optional toolset to use, 輸入 "host=x64"
tensorflow_BUILD_SHARED_LIB v
tensorflow_ENABLE_GPU v

問題與解答
D:\TensorFlowB\tensorflow-1.10\tensorflow\stream_executor\dnn.pb.h
This file was generated by a newer version of protoc
which is incompatible with your Protocol Buffer headers.
Please update your headers.

D:\TensorFlowB\tensorflow-1.10\tensorflow\contrib\cmake\external\protobuf.cmake
set(PROTOBUF_TAG v3.6.0)
set(PROTOBUF_TAG v3.6.1)

D:\TensorFlowB\tensorflow-1.10\tensorflow\workspace.bzl

  tf_http_archive(
      name = "protobuf_archive",
      urls = [
          "https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.1.tar.gz",
          "https://github.com/google/protobuf/archive/v3.6.1.tar.gz",
      ],
      sha256 = "3d4e589d81b2006ca603c1ab712c9715a76227293032d05b26fca603f90b3f5b",
      strip_prefix = "protobuf-3.6.1",
  )
  tf_http_archive(
      name = "eigen_archive",
      urls = [
          "https://mirror.bazel.build/bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz",
          "https://bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz",
      ],
      sha256 = "d956415d784fa4e42b6a2a45c32556d6aec9d0a3d8ef48baee2522ab762556a9",
      strip_prefix = "eigen-eigen-fd6845384b86",
      build_file = clean_dep("//third_party:eigen.BUILD"),
      patch_file = clean_dep("//third_party:eigen_half.patch"),
  )

download eigen_half.patch to D:\TensorFlowB\tensorflow-1.10\third_party\eigen_half.patch

build project tf_python_build_pip_package 產生
EXEC : error : [WinError 5] 存取被拒。:
'build\\bdist.win-amd64\\wheel\\tensorflow_gpu-1.10.1.data\\purelib\\tensorflow\\include\\tensorflow\\stream_executor\\dnn.pb.h'
改變 dnn.pb.h 檔案屬性
使用 Administrator 開啟 vs2015 x64 Native Tools Command Prompt
D:\TensorFlowB\build-1.10>D:\Anaconda3\envs\tensorflow-1.10\python.exe D:/TensorFlowB/build-1.10/tf_python/setup.py bdist_wheel --project_name tensorflow_gpu
另外開啟 Anaconda
(base) D:\TensorFlowB\build-1.10\tf_python>activate tensorflow-1.10
(tensorflow-1.10) D:\TensorFlowB\build-1.10\tf_python>pip install dist\tensorflow_gpu-1.10.1-cp36-cp36m-win_amd64.whl

bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
失敗,沒有到解決方法
c:\users\mark\appdata\local\temp\nvcc_inter_files_tmp_dir\depthwise_conv_op_gpu.cu.compute_70.cudafe1.stub.c(3):
fatal error C1083: Cannot open include file: 'depthwise_conv_op_gpu.cu.fatbin.c': No such file or directory

沒有留言:

張貼留言