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

Commit e3a92c2

Browse files
committed
Update ubuntu install instructions from source
1 parent 092af36 commit e3a92c2

File tree

1 file changed

+69
-23
lines changed

1 file changed

+69
-23
lines changed

docs/install/ubuntu_setup.md

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,30 @@ On Ubuntu versions 16.04 or later, you need the following dependencies:
140140
**Step 1:** Install build tools and git.
141141
```bash
142142
sudo apt-get update
143-
sudo apt-get install -y build-essential git
143+
sudo apt-get install -y build-essential git ninja-build ccache
144144
```
145145

146+
**For Ubuntu 18.04 you need to update CMake to a version >= 3.12**
147+
148+
```bash
149+
#!/usr/bin/env bash
150+
set -exuo pipefail
151+
sudo apt remove --purge --auto-remove cmake
152+
153+
# Update CMAKE for correct cuda autotedetection: https://github.com/clab/dynet/issues/1457
154+
version=3.14
155+
build=0
156+
mkdir -p ~/tmp
157+
cd ~/tmp
158+
wget https://cmake.org/files/v$version/cmake-$version.$build.tar.gz
159+
tar -xzvf cmake-$version.$build.tar.gz
160+
cd cmake-$version.$build/
161+
./bootstrap
162+
make -j$(nproc)
163+
sudo make install
164+
```
165+
166+
146167
**Step 2:** Install a Math Library.
147168

148169
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.
@@ -170,44 +191,69 @@ If building on CPU and using OpenBLAS:
170191
```bash
171192
git clone --recursive https://github.com/apache/incubator-mxnet.git
172193
cd incubator-mxnet
173-
echo "USE_OPENCV = 1" >> ./config.mk
174-
echo "USE_BLAS = openblas" >> ./config.mk
175-
make -j $(nproc)
194+
```
195+
196+
197+
```bash
198+
rm -rf build
199+
mkdir -p build && cd build
200+
cmake -GNinja \
201+
-DUSE_CUDA=OFF \
202+
-DUSE_MKL_IF_AVAILABLE=OFF \
203+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
204+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
205+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
206+
..
207+
ninja
176208
```
177209

178210
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)):
179211

180212
```bash
181-
git clone --recursive https://github.com/apache/incubator-mxnet.git
182-
cd incubator-mxnet
183-
echo "USE_OPENCV = 1" >> ./config.mk
184-
echo "USE_BLAS = openblas" >> ./config.mk
185-
echo "USE_CUDA = 0" >> ./config.mk
186-
echo "USE_MKLDNN = 1" >> ./config.mk
187-
make -j $(nproc)
213+
rm -rf build
214+
mkdir -p build && cd build
215+
cmake -GNinja \
216+
-DUSE_CUDA=OFF \
217+
-DUSE_MKL_IF_AVAILABLE=ON \
218+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
219+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
220+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
221+
..
222+
ninja
188223
```
189224

190225
If building on GPU and you want OpenCV and OpenBLAS (make sure you have installed the [CUDA dependencies first](#cuda-dependencies)):
191226

192227
```bash
193-
git clone --recursive https://github.com/apache/incubator-mxnet.git
194-
cd incubator-mxnet
195-
echo "USE_OPENCV = 1" >> ./config.mk
196-
echo "USE_BLAS = openblas" >> ./config.mk
197-
echo "USE_CUDA = 1" >> ./config.mk
198-
echo "USE_CUDA_PATH = /usr/local/cuda" >> ./config.mk
199-
echo "USE_CUDNN = 1" >> ./config.mk
200-
make -j $(nproc)
228+
cmake -GNinja \
229+
-DUSE_CUDA=ON \
230+
-DUSE_MKL_IF_AVAILABLE=ON \
231+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
232+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
233+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
234+
..
235+
ninja
201236
```
202237

203-
*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).
238+
*Note* - You can explore and use more compilation options in `CMakeLists.txt` and also review common [usage examples](build_from_source.html#usage-examples).
239+
You can also use a scripted version of the above with an editable CMake options file by doing the
240+
following:
241+
242+
```bash
243+
cp cmake/cmake_options.yml .
244+
# Edit to your taste
245+
$EDITOR cmake_options.yml
246+
# Launch a local CMake build
247+
./dev_menu.py menu 1
248+
```
204249

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

207-
You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH`:
252+
You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH` and `MXNET_LIBRARY_PATH` accordingly:
208253

209254
```bash
210-
export LD_LIBRARY_PATH=$PWD/lib
255+
export LD_LIBRARY_PATH=`realpath build`
256+
export MXNET_LIBRARY_PATH=`realpath build/libmxnet.so`
211257
```
212258

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

0 commit comments

Comments
 (0)