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

Commit

Permalink
Update ubuntu install instructions from source
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy committed Mar 26, 2019
1 parent 092af36 commit 8e85178
Showing 1 changed file with 73 additions and 24 deletions.
97 changes: 73 additions & 24 deletions docs/install/ubuntu_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,30 @@ On Ubuntu versions 16.04 or later, you need the following dependencies:
**Step 1:** Install build tools and git.
```bash
sudo apt-get update
sudo apt-get install -y build-essential git
sudo apt-get install -y build-essential git ninja-build ccache
```

**For Ubuntu 18.04 and CUDA builds you need to update CMake**

```bash
#!/usr/bin/env bash
set -exuo pipefail
sudo apt remove --purge --auto-remove cmake

# Update CMAKE for correct cuda autotedetection: https://github.com/clab/dynet/issues/1457
version=3.14
build=0
mkdir -p ~/tmp
cd ~/tmp
wget https://cmake.org/files/v$version/cmake-$version.$build.tar.gz
tar -xzvf cmake-$version.$build.tar.gz
cd cmake-$version.$build/
./bootstrap
make -j$(nproc)
sudo make install
```


**Step 2:** Install a Math Library.

Details on the different math libraries are found in the build from source guide's [Math Library Selection](build_from_source.html#math-library-selection) section.
Expand Down Expand Up @@ -170,44 +191,72 @@ If building on CPU and using OpenBLAS:
```bash
git clone --recursive https://github.com/apache/incubator-mxnet.git
cd incubator-mxnet
echo "USE_OPENCV = 1" >> ./config.mk
echo "USE_BLAS = openblas" >> ./config.mk
make -j $(nproc)
```


```bash
rm -rf build
mkdir -p build && cd build
cmake -GNinja \
-DUSE_CUDA=OFF \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
..
ninja
```

If building on CPU and using MKL and MKL-DNN (make sure MKL is installed according to [Math Library Selection](build_from_source.html#math-library-selection) and [MKL-DNN README](https://github.com/apache/incubator-mxnet/blob/master/docs/tutorials/mkldnn/MKLDNN_README.md)):

```bash
git clone --recursive https://github.com/apache/incubator-mxnet.git
cd incubator-mxnet
echo "USE_OPENCV = 1" >> ./config.mk
echo "USE_BLAS = openblas" >> ./config.mk
echo "USE_CUDA = 0" >> ./config.mk
echo "USE_MKLDNN = 1" >> ./config.mk
make -j $(nproc)
rm -rf build
mkdir -p build && cd build
cmake -GNinja \
-DUSE_CUDA=OFF \
-DUSE_MKL_IF_AVAILABLE=ON \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
..
ninja
```

If building on GPU and you want OpenCV and OpenBLAS (make sure you have installed the [CUDA dependencies first](#cuda-dependencies)):
If building on GPU (make sure you have installed the [CUDA dependencies first](#cuda-dependencies)):
Cuda 10.1 in Ubuntu 18.04 builds fine but is not currently tested in CI.

```bash
git clone --recursive https://github.com/apache/incubator-mxnet.git
cd incubator-mxnet
echo "USE_OPENCV = 1" >> ./config.mk
echo "USE_BLAS = openblas" >> ./config.mk
echo "USE_CUDA = 1" >> ./config.mk
echo "USE_CUDA_PATH = /usr/local/cuda" >> ./config.mk
echo "USE_CUDNN = 1" >> ./config.mk
make -j $(nproc)
rm -rf build
mkdir -p build && cd build
cmake -GNinja \
-DUSE_CUDA=ON \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
..
ninja
```

*Note* - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in `make/config.mk` and also review common [usage examples](build_from_source.html#usage-examples).
*Note* - You can explore and use more compilation options in `CMakeLists.txt` and also review common [usage examples](build_from_source.html#usage-examples).
You can also use a scripted version of the above with an editable CMake options file by doing the
following:

```bash
cp cmake/cmake_options.yml .
# Edit to your taste
$EDITOR cmake_options.yml
# Launch a local CMake build
./dev_menu.py menu 1
```

Building from source creates a library called ```libmxnet.so``` in the `lib` folder in your MXNet project root.
Building from source creates a library called ```libmxnet.so``` in the `build` folder in your MXNet project root.

You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH`:
You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH` and `MXNET_LIBRARY_PATH` accordingly:

```bash
export LD_LIBRARY_PATH=$PWD/lib
export LD_LIBRARY_PATH=`realpath build`
export MXNET_LIBRARY_PATH=`realpath build/libmxnet.so`
```

After building the MXNet library, you may install language bindings.
Expand Down

0 comments on commit 8e85178

Please sign in to comment.