|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | + |
| 20 | +# This script builds the libraries of mxnet. |
| 21 | +make_config=config/pip_${PLATFORM}_${VARIANT}.mk |
| 22 | +if [[ ! -f $make_config ]]; then |
| 23 | + >&2 echo "Couldn't find make config $make_config for the current settings." |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +git clone --recursive https://github.com/apache/incubator-mxnet mxnet-build |
| 28 | + |
| 29 | +>&2 echo "Now building mxnet modules..." |
| 30 | +cp $make_config mxnet-build/config.mk |
| 31 | + |
| 32 | +cd mxnet-build |
| 33 | + |
| 34 | +make DEPS_PATH=$DEPS_PATH DMLCCORE |
| 35 | +make DEPS_PATH=$DEPS_PATH $PWD/3rdparty/tvm/nnvm/lib/libnnvm.a |
| 36 | +make DEPS_PATH=$DEPS_PATH PSLITE |
| 37 | + |
| 38 | +if [[ $VARIANT == *mkl ]]; then |
| 39 | + MKLDNN_LICENSE='license.txt' |
| 40 | + if [[ $PLATFORM == 'linux' ]]; then |
| 41 | + IOMP_LIBFILE='libiomp5.so' |
| 42 | + MKLML_LIBFILE='libmklml_intel.so' |
| 43 | + MKLDNN_LIBFILE='libmkldnn.so.0' |
| 44 | + else |
| 45 | + IOMP_LIBFILE='libiomp5.dylib' |
| 46 | + MKLML_LIBFILE='libmklml.dylib' |
| 47 | + MKLDNN_LIBFILE='libmkldnn.0.dylib' |
| 48 | + fi |
| 49 | + make DEPS_PATH=$DEPS_PATH mkldnn |
| 50 | + cp 3rdparty/mkldnn/LICENSE ./MKLML_LICENSE |
| 51 | +fi |
| 52 | + |
| 53 | +if [[ $VARIANT == *mkl ]]; then |
| 54 | + >&2 echo "Copying MKL license." |
| 55 | + rm lib/libmkldnn.{so,dylib} |
| 56 | + rm lib/libmkldnn.0.*.dylib |
| 57 | + rm lib/libmkldnn.so.0.* |
| 58 | +fi |
| 59 | + |
| 60 | +>&2 echo "Now building mxnet..." |
| 61 | +make DEPS_PATH=$DEPS_PATH || exit 1; |
| 62 | + |
| 63 | +if [[ $PLATFORM == 'linux' ]]; then |
| 64 | + cp -L /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.so lib/libgfortran.so.3 |
| 65 | + cp -L /usr/lib/x86_64-linux-gnu/libquadmath.so.0 lib/libquadmath.so.0 |
| 66 | +fi |
| 67 | + |
| 68 | +# Print the linked objects on libmxnet.so |
| 69 | +>&2 echo "Checking linked objects on libmxnet.so..." |
| 70 | +if [[ ! -z $(command -v readelf) ]]; then |
| 71 | + readelf -d lib/libmxnet.so |
| 72 | + strip --strip-unneeded lib/libmxnet.so |
| 73 | +elif [[ ! -z $(command -v otool) ]]; then |
| 74 | + otool -L lib/libmxnet.so |
| 75 | + strip -u -r -x lib/libmxnet.so |
| 76 | +else |
| 77 | + >&2 echo "Not available" |
| 78 | +fi |
| 79 | + |
| 80 | +cd ../ |
0 commit comments