Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
build scripts for lib and wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
szha committed Dec 14, 2018
1 parent f40b86e commit 17f2ea5
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tools/build/build_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# This script builds the libraries of mxnet.
make_config=config/pip_${PLATFORM}_${VARIANT}.mk
if [[ ! -f $make_config ]]; then
>&2 echo "Couldn't find make config $make_config for the current settings."
exit 1
fi

git clone --recursive https://github.com/apache/incubator-mxnet mxnet-build

>&2 echo "Now building mxnet modules..."
cp $make_config mxnet-build/config.mk

cd mxnet-build

$MAKE DEPS_PATH=$DEPS_PATH DMLCCORE
$MAKE DEPS_PATH=$DEPS_PATH $PWD/3rdparty/tvm/nnvm/lib/libnnvm.a
$MAKE DEPS_PATH=$DEPS_PATH PSLITE

if [[ $VARIANT == *mkl ]]; then
MKLDNN_LICENSE='license.txt'
if [[ $PLATFORM == 'linux' ]]; then
IOMP_LIBFILE='libiomp5.so'
MKLML_LIBFILE='libmklml_intel.so'
MKLDNN_LIBFILE='libmkldnn.so.0'
else
IOMP_LIBFILE='libiomp5.dylib'
MKLML_LIBFILE='libmklml.dylib'
MKLDNN_LIBFILE='libmkldnn.0.dylib'
fi
$MAKE DEPS_PATH=$DEPS_PATH mkldnn
cp 3rdparty/mkldnn/LICENSE ./MKLML_LICENSE
fi

if [[ $VARIANT == *mkl ]]; then
>&2 echo "Copying MKL license."
rm lib/libmkldnn.{so,dylib}
rm lib/libmkldnn.0.*.dylib
rm lib/libmkldnn.so.0.*
fi

>&2 echo "Now building mxnet..."
$MAKE DEPS_PATH=$DEPS_PATH || exit 1;

if [[ $PLATFORM == 'linux' ]]; then
cp -L /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.so lib/libgfortran.so.3
cp -L /usr/lib/x86_64-linux-gnu/libquadmath.so.0 lib/libquadmath.so.0
fi

# Print the linked objects on libmxnet.so
>&2 echo "Checking linked objects on libmxnet.so..."
if [[ ! -z $(command -v readelf) ]]; then
readelf -d lib/libmxnet.so
strip --strip-unneeded lib/libmxnet.so
elif [[ ! -z $(command -v otool) ]]; then
otool -L lib/libmxnet.so
strip -u -r -x lib/libmxnet.so
else
>&2 echo "Not available"
fi

cd ../
31 changes: 31 additions & 0 deletions tools/build/build_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# This script builds the wheel for binary distribution and performs sanity check.

cd mxnet-build
echo $(git rev-parse HEAD) >> python/mxnet/COMMIT_HASH
cd -

# Make wheel for testing
python setup.py bdist_wheel

wheel_name=$(ls -t dist | head -n 1)
pip install -U --user --force-reinstall dist/$wheel_name
python sanity_test.py

0 comments on commit 17f2ea5

Please sign in to comment.