apeforest commented on a change in pull request #17602: Fix OS X staticbuild, update docs and add tests URL: https://github.com/apache/incubator-mxnet/pull/17602#discussion_r379878482
########## File path: docs/static_site/src/pages/get_started/osx_setup.md ########## @@ -24,176 +24,151 @@ permalink: /get_started/osx_setup # Installing MXNet from source on OS X (Mac) -**NOTE:** For pre-built MXNet with Python, please refer to the [new install guide]({{'/get_started'|relative_url}}). +The following installation instructions are for building MXNet from source. For +instructions to build MXNet from source on other platforms, see the general +[Build From Source guide](build_from_source). -Installing MXNet is a two-step process: +Instead of building from source, you can install a binary version of MXNet. For +that, please follow the information at [Get Started](get_started). -1. Build the shared library from the MXNet C++ source code. -2. Install the supported language-specific packages for MXNet. +Building MXNet from source is a two-step process: -**Note:** To change the compilation options for your build, edit the ```make/config.mk``` file and submit a build request with the ```make``` command. +1. Build the shared library from the MXNet C++ source code. +2. (optional) Install the supported language-specific packages for MXNet. -## Prepare Environment for GPU Installation +If you plan to build with GPU, you need to set up the environment for CUDA and +cuDNN. Please follow the [NVIDIA CUDA Installation Guide for Mac OS +X](https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html) and +[cuDNN Installation +Guide](https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#install-mac). +Note that CUDA stopped supporting macOS in 2019 and future versions of CUDA may +not support macOS. -This section is optional. Skip to next section if you don't plan to use GPUs. If you plan to build with GPU, you need to set up the environment for CUDA and cuDNN. +## Contents -First, download and install [CUDA 8 toolkit](https://developer.nvidia.com/cuda-toolkit). +* [Build the MXNet shared library from source](#build-mxnet-from-source) +* [Install Language Packages](#installing-language-packages-for-mxnet) + * [R](#install-the-mxnet-package-for-r) + * [Julia](#install-the-mxnet-package-for-julia) + * [Scala](#install-the-mxnet-package-for-scala) + * [Java](#install-the-mxnet-package-for-java) + * [Perl](#install-the-mxnet-package-for-perl) + * [Contributions](#contributions) + * [Next Steps](#next-steps) -Once you have the CUDA Toolkit installed you will need to set up the required environment variables by adding the following to your ~/.bash_profile file: +<hr> -```bash - export CUDA_HOME=/usr/local/cuda - export DYLD_LIBRARY_PATH="$CUDA_HOME/lib:$DYLD_LIBRARY_PATH" - export PATH="$CUDA_HOME/bin:$PATH" -``` -Reload ~/.bash_profile file and install dependencies: -```bash - . ~/.bash_profile - brew install coreutils - brew tap caskroom/cask -``` +## Build the MXNet shared library from source -Then download [cuDNN 5](https://developer.nvidia.com/cudnn). +On OS X, you need the following dependencies: -Unzip the file and change to the cudnn root directory. Move the header files and libraries to your local CUDA Toolkit folder: +**Step 1:** Install prerequisite packages. ```bash - $ sudo mv include/cudnn.h /Developer/NVIDIA/CUDA-8.0/include/ - $ sudo mv lib/libcudnn* /Developer/NVIDIA/CUDA-8.0/lib - $ sudo ln -s /Developer/NVIDIA/CUDA-8.0/lib/libcudnn* /usr/local/cuda/lib/ -``` +# Install OS X Developer Tools +xcode-select --install + +# Install Homebrew +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -Now we can start to build MXNet. +# Install dependencies +brew install cmake ninja ccache opencv +``` -## Build the Shared Library +`opencv` is an optional dependency. You can delete it from above `brew install` +line and build MXNet without OpenCV support by setting `USE_OPENCV` to `OFF` in +the configuration file described below. -### Install MXNet dependencies -Install the dependencies, required for MXNet, with the following commands: -- [Homebrew](http://brew.sh/) -- OpenBLAS and homebrew/core (for linear algebraic operations) -- OpenCV (for computer vision operations) -```bash - # Paste this command in Mac terminal to install Homebrew - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +**Step 2:** Download MXNet sources and configure - # Insert the Homebrew directory at the top of your PATH environment variable - export PATH=/usr/local/bin:/usr/local/sbin:$PATH -``` +Clone the repository: ```bash - brew update - brew install pkg-config - brew install graphviz - brew install openblas - brew tap homebrew/core - brew install opencv - - # If building with MKLDNN - brew install llvm - - # Get pip - easy_install pip - # For visualization of network graphs - pip install graphviz==0.8.4 - # Jupyter notebook - pip install jupyter +git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet +cd mxnet +cp config/darwin.cmake config.cmake ``` -### Build MXNet Shared Library +Please edit the config.cmake file based on your needs. The file contains a +series of `set(name value CACHE TYPE "Description")` entries. For example, to +build without Cuda, change `set(USE_CUDA ON CACHE TYPE "Build with CUDA +support")` to `set(USE_CUDA OFF CACHE TYPE "Build with CUDA support")`. + +For a GPU-enabled build make sure you have installed the [CUDA dependencies +first](#cuda-dependencies)). When building a GPU-enabled build on a machine +without GPU, MXNet build can't autodetect your GPU architecture and will target +all available GPU architectures. Please set the `MXNET_CUDA_ARCH` variable in +`config.cmake` to your desired cuda architecture to speed up the build. -After you have installed the dependencies, pull the MXNet source code from Git and build MXNet to produce an MXNet library called ```libmxnet.so```. You can clone the repository as described in the following code block, or you may try the [download links](download) for your desired MXNet version. +To (optionally) build with MKL math library, please install MKL first based on +the guide in [Math Library Selection](build_from_source#math-library-selection). -The file called ```osx.mk``` has the configuration required for building MXNet on OS X. First copy ```make/osx.mk``` into ```config.mk```, which is used by the ```make``` command: +**Step 3:** Build MXNet core shared library. Review comment: These instructions and everything below seem to be identical to linux setup instruction. Could we consolidate them to reduce duplication? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to 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