module purge -f
module load apps/git compilers/gcc/4.8.5 apps/buildtools
git clone https://github.com/google/protobuf.git
cd protobuf
export CXXFLAGS='-fPIC'
export CFLAGS='-fPIC'
./configure
make -j8
cd python
OLD_PATH=$PATH
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export PATH=$PWD/../src/.libs:$PATH
export LD_LIBRARY_PATH=$PWD/../src/.libs:$LD_LIBRARY_PATH
# Build Python 3.5 wheel
module load apps/python/3.5
pyvenv buildenv3
source buildenv3/bin/activate
pip install wheel
python setup.py bdist_wheel --cpp_implementation --compile_static_extension
deactivate
# Build Python 2.7 wheel
module swap apps/python/3.5 apps/python/2.7
virtualenv buildenv
source buildenv/bin/activate
pip install wheel
python setup.py bdist_wheel --cpp_implementation --compile_static_extension
deactivate
# Install wheels
cp dist/*.whl /software6/apps/python/wheelhouse/gcc
# Restore environment
export PATH=$OLD_PATH
export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH
Last active
July 21, 2016 15:11
-
-
Save cmd-ntrf/dcd493e82a994a8c434698de185d404c to your computer and use it in GitHub Desktop.
Instruction to build TensorFlow for Python 3.5 on Helios
module purge -f
module load compilers/gcc/4.8.5 compilers/java/1.8 apps/buildtools cuda/7.5 libs/cuDNN/5 compilers/swig apps/git apps/python/3.5 apps/bazel/0.3.0
wget https://github.com/tensorflow/tensorflow/archive/v0.9.0.tar.gz
tar xvf v0.9.0.tar.gz
mv tensorflow-0.9.0{,-3.5}
# Adapt CROSSTOOL file for Tensorflow
cp third_party/gpus/crosstool/CROSSTOOL{,.orig}
for tool in gcc cpp gcov ar ld dwp nm objdump objcopy strip; do
sed -i "s;/usr/bin/$tool;$(which $tool);g" third_party/gpus/crosstool/CROSSTOOL
done
GCC_PREFIX=$(dirname $(dirname $(which gcc)))
sed -i "\;linker_flag: \"-B/usr/bin/\";a \
\ \ linker_flag: \"-Wl,-rpath=$GCC_PREFIX/lib64\"" third_party/gpus/crosstool/CROSSTOOL
sed -i "\;linker_flag: \"-B/usr/bin/\";a \
\ \ linker_flag: \"-Wl,-rpath=$GCC_PREFIX/lib\"" third_party/gpus/crosstool/CROSSTOOL
# Include directory
for path in $(find $GCC_PREFIX -name include\*); do
sed -i "\;cxx_builtin_include_directory: \"/usr/local/include\"; a \
\ \ cxx_builtin_include_directory: \"$path\"" third_party/gpus/crosstool/CROSSTOOL
done
TOOLS_PREFIX=$(dirname $(which ar))
sed -i "s;-B/usr/bin;-B$TOOLS_PREFIX;g" third_party/gpus/crosstool/CROSSTOOL
# Configure Python environment
pyvenv buildenv
source buildenv/bin/activate
pip install numpy wheel
# Configure
./configure
# Python - default
# with Google Cloud Platform: N
# with GPU: Y
# GCC - default
# CUDA version: 7.5
# CUDA path : /software-gpu/cuda/7.5.18
# cuDNN : 5
# cuDNN path : /software-gpu/libs/cuDNN/5_cuda7.5
# Compute capability : 3.5,3.7
# Adapt crosstool wrapper
sed -i "1 s;^.*$;#!$VIRTUAL_ENV/bin/python;" third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
sed -i "/cmd = 'PATH=' + PREFIX_DIR + ' ' + cmd/s/^/#/" third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
2to3 -w third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
# Update protobuf version number (3.0.0-beta-2 C++ version is not compatible with Python 3)
sed -i "s;'protobuf == 3.0.0b2';'protobuf == 3.0.0b4';g" tensorflow/tools/pip_package/setup.py
# Control memory problem with java
export MALLOC_ARENA_MAX=4
# Build Tensorflow
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package --verbose_failures --jobs 40
# Creating wheel
mkdir dist
bazel-bin/tensorflow/tools/pip_package/build_pip_package $PWD/dist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment