Switch open-source to use jemalloc for CPU Tensor memory allocation, gRPC, and other places where we call malloc/free.
- Only enabled on Linux for now.
- Added as a ./configure option defaulting to enabled.
Change: 144266237
diff --git a/configure b/configure
index 64add33..1e4d786 100755
--- a/configure
+++ b/configure
@@ -57,9 +57,27 @@
if is_windows; then
TF_NEED_GCP=0
TF_NEED_HDFS=0
+ TF_NEED_JEMALLOC=0
TF_NEED_OPENCL=0
fi
+while [ "$TF_NEED_JEMALLOC" == "" ]; do
+ read -p "Do you wish to use jemalloc as the malloc implementation? "\
+"(Linux only) [Y/n] " INPUT
+ case $INPUT in
+ [Yy]* ) echo "jemalloc enabled on Linux"; TF_NEED_JEMALLOC=1;;
+ [Nn]* ) echo "jemalloc disabled on Linux"; TF_NEED_JEMALLOC=0;;
+ "" ) echo "jemalloc enabled on Linux"; TF_NEED_JEMALLOC=1;;
+ * ) echo "Invalid selection: " $INPUT;;
+ esac
+done
+
+if [ "$TF_NEED_JEMALLOC" == "1" ]; then
+ sed -i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
+else
+ sed -i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
+fi
+
while [ "$TF_NEED_GCP" == "" ]; do
read -p "Do you wish to build TensorFlow with "\
"Google Cloud Platform support? [y/N] " INPUT