Google Tensorflow 源码编译,一:Protobuf

这几天终于把tensorflow安装上了,中间遇到过不少的问题,这里记录下来。供大家想源码安装的参考。

安装环境:POWER8处理器,Docker容器Ubuntu14.04镜像。

Build Protobuf<v3.0.0-alpha-3> for IBM POWER8 CPU from Source Code

My computer\'s os is ubuntu 14.04 , and I want to install protobuf v3.0.0-alpha-3, but there is no deb package in the repository, so I need to build from source code.

Here are the steps that I succeed to install protobuf<v3.0.0-alpha-3> on my computer:

1. Get source code

1.1 Get protobuf code

  git clone https://github.com/google/protobuf

  git checkout v3.0.0-alpha-3

1.2 Get gtest code

  The latest protobuf version uses gmock, but v3.0.0-alpha-3 uses gtest. Anyway ,the following code always works!

  git clone https://github.com/franramirez688/gmock(../ is the root path of protobuf)

  cp ./gmock/gtest ../

2. Modify the code to support POWER cpu

2.1 Add g++ MACRO

  in protobuf/src/google/protobuf/stubs/platform_macros.h:

  change #elif defined(_POWER) to #elif defined(_POWER) || defined(__powerpc64__) || defined(__PPC64__).

2.2 Include power cpu header file

  in protobuf/src/google/protobuf/stubs/atomicops.h, add:

  if defined(GOOGLE_PROTOBUF_ARCH_POWER)

  #include <google/protobuf/stubs/atomicops_internals_power.h>

  endif

2.3 Add power cpu header file

  add atomicops_internals_power.h to google/protobuf/stubs folder:

  you can copy it from the latest version < v3.0.0-beta-1>

3. Compile source code

  $ ./autogen.sh

  $ ./configure

  $ make

  $ make install

4. the binary file <protoc> is saved at protobuf/src/protoc.