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

Commit 12eed6d

Browse files
committed
Update ubuntu install instructions from source
1 parent 33b6543 commit 12eed6d

File tree

1 file changed

+73
-24
lines changed

1 file changed

+73
-24
lines changed

docs/install/ubuntu_setup.md

Lines changed: 73 additions & 24 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 and CUDA builds you need to update CMake**
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,72 @@ 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

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

192228
```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)
229+
rm -rf build
230+
mkdir -p build && cd build
231+
cmake -GNinja \
232+
-DUSE_CUDA=ON \
233+
-DUSE_MKL_IF_AVAILABLE=OFF \
234+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
235+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
236+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
237+
..
238+
ninja
201239
```
202240

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

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

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

209257
```bash
210-
export LD_LIBRARY_PATH=$PWD/lib
258+
export LD_LIBRARY_PATH=`realpath build`
259+
export MXNET_LIBRARY_PATH=`realpath build/libmxnet.so`
211260
```
212261

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

0 commit comments

Comments
 (0)