Skip to content

Instantly share code, notes, and snippets.

@cmd-ntrf
Last active January 4, 2017 16:43
Show Gist options
  • Save cmd-ntrf/f9430dc3bf33e9089ad95169ed41c28b to your computer and use it in GitHub Desktop.
Save cmd-ntrf/f9430dc3bf33e9089ad95169ed41c28b to your computer and use it in GitHub Desktop.
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/bazel/0.4.3

mkdir -p /tmp/$USER
cd /tmp/$USER

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow

git checkout 0.12.1

#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.tpl
#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.tpl
sed -i "\;linker_flag: \"-B/usr/bin/\";a \
\ \ linker_flag: \"-Wl,-rpath=$GCC_PREFIX/lib\"" third_party/gpus/crosstool/CROSSTOOL.tpl

#for path in $(find $GCC_PREFIX -name include\*) ${CPATH//:/ }
#do
#sed -i "\;cxx_builtin_include_directory: \"/usr/local/include\"; a \
#\ \ cxx_builtin_include_directory: \"$path\"" third_party/gpus/crosstool/CROSSTOOL.tpl
#done

#sed -i "s;-B/usr/bin;-B$(dirname $(which ar));g" third_party/gpus/crosstool/CROSSTOOL.tpl

sed -i "/cmd = 'PATH=' + PREFIX_DIR + ' ' + cmd/s/^/#/" third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl
 
# Bug in Zlib for Bazel 0.12.1
sed -i 's;zlib-1.2.8.tar.gz;fossils/zlib-1.2.8.tar.gz;g' tensorflow/workspace.bzl
 
module load apps/python/2
virtualenv buildenv
source buildenv/bin/activate
pip install numpy wheel

sed -i "s;bazel fetch; bazel --output_base=/tmp/$USER/bazel_output fetch;g" configure

sed -i "s;_VERSION = '0.12.1';_VERSION = '0.12.1+helios';g" tensorflow/tools/pip_package/setup.py
 
echo -e "\nN\nN\n\nN\nY\n\n7.5\n/software-gpu/cuda/7.5.18\n5\n/software-gpu/libs/cuDNN/5_cuda7.5\n3.5,3.7\n" | MALLOC_ARENA_MAX=4 ./configure
# Python - default
# with Google Cloud Platform: N
# with HDFS: N
# Python library path - default
# OpenCL support: 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

MALLOC_ARENA_MAX=4 bazel --output_base=/tmp/$USER/bazel_output build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

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