diff --git a/deps/build.jl b/deps/build.jl index 38c8e19c2..a16afe6aa 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -73,6 +73,7 @@ const CC = get(ENV, "CC", nothing) const CXX = get(ENV, "CXX", nothing) const ADD_CFLAGS = get(ENV, "ADD_CFLAGS", nothing) const ADD_LDFLAGS = get(ENV, "ADD_LDFLAGS", nothing) +const USE_JEMALLOC = get(ENV, "USE_JEMALLOC", nothing) # "0" or "1" function get_cpucore() if haskey(ENV, "TRAVIS") # on travis-ci @@ -238,6 +239,9 @@ if !libmxnet_detected if ADD_LDFLAGS != nothing `sed -i -s "s@ADD_LDFLAGS =\(.*\)@ADD_LDFLAGS =\1 $ADD_LDFLAGS@" config.mk` end + if USE_JEMALLOC != nothing + `sed -i -s "s@USE_JEMALLOC =\(.*\)@USE_JEMALLOC = $USE_JEMALLOC@" config.mk` + end if USE_JULIA_BLAS `make -j$(get_cpucore()) USE_BLAS=$blas_name $MSHADOW_LDFLAGS` diff --git a/docs/src/user-guide/install.md b/docs/src/user-guide/install.md index dd1262b47..f1d5eeefa 100644 --- a/docs/src/user-guide/install.md +++ b/docs/src/user-guide/install.md @@ -37,6 +37,15 @@ There are several environment variables that change this behaviour. if you need to point non-standard include directory, please set it as `ENV["ADD_CFLAGS"] = "-I'/path/to/include/dir'"`. - `ADD_LDFLAGS`: Additional linker flags. +- `USE_JEMALLOC`: Default is enabled if jemalloc available. + If you ran into segfault cause by jemalloc, + Please try to disable it. + + ```julia + # first remove whole libmxnet source: Pkg.dir("MXNet", "deps", "src") + ENV["USE_JEMALLOC"] = "0" + Pkg.build("MXNet") + ``` The libmxnet source is downloaded to `Pkg.dir("MXNet", "deps", "src", "mxnet")`. The automatic build is using default configurations, with OpenCV disabled.