expnn opened a new issue #8617: Failed to detect tcmalloc or jemalloc for 
Fedora 26
URL: https://github.com/apache/incubator-mxnet/issues/8617
 
 
   The wildcard given by the current Makefile failed to detect the 
gperftools/jemalloc malloc libraries. 
   Currently, it uses the following snippet to detect these libraries, which 
assumes the `.so` file is located in the '*/lib' subdirectories. 
   
https://github.com/apache/incubator-mxnet/blob/35ceea73ccc1acfb2ec62cdaa841822e51c13456/Makefile#L168-L213
   
   This is not true for Fedora 26 (and for many 64-bit systems), which put the 
shared library files into 'lib64' subdirectories. For example, on my system, it 
is located in the `/usr/lib64` directory. 
   ```bash
   $ locate libtcmalloc.so
   /usr/lib64/libtcmalloc.so.4
   /usr/lib64/libtcmalloc.so.4.4.5
   ```
   I suggest to using the following snippet to replace the above-mentioned 
codes.
   It simply replaces 'lib' into 'lib*' in the wildcard matching.  
   ```Makefile
   # gperftools malloc library (tcmalloc)
   ifeq ($(USE_GPERFTOOLS), 1)
   #    FIND_LIBNAME=tcmalloc_and_profiler
        FIND_LIBNAME=tcmalloc
        FIND_LIBFILEEXT=so
        FIND_LIBFILE=$(wildcard /lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
        ifeq (,$(FIND_LIBFILE))
                FIND_LIBFILE=$(wildcard 
/usr/lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                ifeq (,$(FIND_LIBFILE))
                        FIND_LIBFILE=$(wildcard 
/usr/local/lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                        ifeq (,$(FIND_LIBFILE))
                                USE_GPERFTOOLS=0
                        endif
                endif
        endif
        ifeq ($(USE_GPERFTOOLS), 1)
                CFLAGS += -fno-builtin-malloc -fno-builtin-calloc 
-fno-builtin-realloc -fno-builtin-free
                LDFLAGS += $(FIND_LIBFILE)
        endif
   endif
   
   # jemalloc malloc library (if not using gperftools)
   ifneq ($(USE_GPERFTOOLS), 1)
        ifeq ($(USE_JEMALLOC), 1)
                FIND_LIBNAME=jemalloc
                FIND_LIBFILEEXT=so
                FIND_LIBFILE=$(wildcard 
/lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                ifeq (,$(FIND_LIBFILE))
                        FIND_LIBFILE=$(wildcard 
/usr/lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                        ifeq (,$(FIND_LIBFILE))
                                FIND_LIBFILE=$(wildcard 
/usr/local/lib*/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                                ifeq (,$(FIND_LIBFILE))
                                        FIND_LIBFILE=$(wildcard 
/usr/lib*/x86_64-linux-gnu/lib$(FIND_LIBNAME).$(FIND_LIBFILEEXT))
                                        ifeq (,$(FIND_LIBFILE))
                                                USE_JEMALLOC=0
                                        endif
                                endif
                        endif
                endif
                ifeq ($(USE_JEMALLOC), 1)
                        CFLAGS += -fno-builtin-malloc -fno-builtin-calloc 
-fno-builtin-realloc \
                        -fno-builtin-free -DUSE_JEMALLOC
                        LDFLAGS += $(FIND_LIBFILE)
                endif
        endif
   endif
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to