forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Mac quick install script for mxnet with Python (apache#4642)
- Loading branch information
1 parent
1ea1078
commit 44bee23
Showing
3 changed files
with
201 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!/bin/bash | ||
# | ||
# This scripts installs the dependencies, downloads MXNet source | ||
# and compiles it. | ||
# | ||
# The script also installs the MXNet package for Python. | ||
# | ||
|
||
#set -ex | ||
|
||
export MXNET_HOME=`pwd`/mxnet | ||
export MXNET_LOG=${MXNET_HOME}/buildMXNet_mac.log | ||
# Insert the Homebrew directory at the top of your PATH environment variable | ||
export PATH=/usr/local/bin:/usr/local/sbin:$PATH | ||
LINE="########################################################################" | ||
|
||
echo $LINE | ||
echo " " | ||
echo "This script installs MXNet on MacOS." | ||
echo "It has been tested to work successfully on MacOS El Capitan and Sierra" | ||
echo "and is expected to work fine on other versions as well." | ||
echo " " | ||
echo $LINE | ||
sleep 2 | ||
|
||
# | ||
# Install dependencies for MXNet | ||
# | ||
|
||
# Install Homebrew | ||
yes '' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
|
||
brew_pkg_install () { | ||
pkg=$1 | ||
brew ls --versions $pkg > /dev/null | ||
ret=$? | ||
if [[ ${ret} != 0 ]]; then | ||
echo "brew install $pkg" | ||
brew install $pkg | ||
else | ||
echo "$pkg already installed" | ||
fi | ||
} | ||
|
||
runme() { | ||
cmd=$* | ||
echo "$cmd" | ||
$cmd | ||
ret=$? | ||
if [[ ${ret} != 0 ]]; then | ||
echo " " | ||
echo "ERROR: Return value non-zero for: $cmd" | ||
echo " " | ||
exit 1 | ||
fi | ||
} | ||
|
||
runme brew update | ||
runme brew_pkg_install pkg-config | ||
runme brew_pkg_install python | ||
runme brew_pkg_install openblas | ||
runme brew_pkg_install opencv | ||
# Needed for /usr/local/lib/graphviz to be created | ||
runme brew_pkg_install graphviz | ||
runme brew_pkg_install numpy | ||
|
||
runme brew tap homebrew/science | ||
|
||
runme pip install graphviz | ||
runme pip install jupyter | ||
runme pip install cython | ||
|
||
# | ||
# Fetch MXNet source and compile it | ||
# | ||
if [ -f ${MXNET_HOME} ]; then | ||
ls -al ${MXNET_HOME} | ||
echo " " | ||
echo "ERROR: ${MXNET_HOME} directory already present" | ||
echo "To correct the problem, please rename the directory or remove it." | ||
echo " " | ||
fi | ||
|
||
runme git clone --recursive https://github.com/dmlc/mxnet | ||
cd ${MXNET_HOME} | ||
runme cp make/osx.mk ./config.mk | ||
runme echo "USE_BLAS = openblas" >> ./config.mk | ||
runme echo "ADD_CFLAGS += -I/usr/local/opt/openblas/include" >> ./config.mk | ||
runme echo "ADD_LDFLAGS += -L/usr/local/opt/openblas/lib" >> ./config.mk | ||
runme echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk | ||
echo " " | ||
echo "Running Make" | ||
echo " " | ||
runme make -j$(sysctl -n hw.ncpu) | ||
|
||
# | ||
# Install MXNet package for Python | ||
# | ||
echo "Installing MXNet package for Python..." | ||
runme cd ${MXNET_HOME}/python | ||
runme sudo python setup.py install | ||
|
||
# | ||
# Test MXNet | ||
# | ||
echo "Testing MXNet now..." | ||
python << END > mxnet_test.log | ||
import mxnet as mx | ||
a = mx.nd.ones((2, 3)); | ||
print ((a*2).asnumpy()); | ||
END | ||
cat << END > mxnet_test.expected | ||
[[ 2. 2. 2.] | ||
[ 2. 2. 2.]] | ||
END | ||
diff mxnet_test.log mxnet_test.expected | ||
if [[ $? = 0 ]]; then | ||
echo $LINE | ||
echo " " | ||
echo "SUCCESS: MXNet test passed" | ||
echo "SUCCESS: MXNet is successfully installed and works fine!" | ||
echo ":-)" | banner -w 40 | ||
echo " " | ||
echo $LINE | ||
exit 0 | ||
else | ||
echo $LINE | ||
echo " " | ||
echo "ERROR: MXNet test failed" | ||
echo ":-(" | banner -w 40 | ||
echo " " | ||
echo $LINE | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.