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

Commit 4586bc5

Browse files
kevinthesunmli
authored andcommitted
[doc] GPU installation for mac and ubuntu (#4325)
* GPU installation for mac and ubuntu * Use default atlas * Small fix * Fix search box
1 parent f92ebf1 commit 4586bc5

File tree

3 files changed

+137
-49
lines changed

3 files changed

+137
-49
lines changed

docs/_static/mxnet.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ img {
253253
top: 15px;
254254
right: 155px;
255255
width: 140px;
256-
z-index: -1;
257256
}
258257

259258
.searchBox {
@@ -293,6 +292,7 @@ img {
293292
left: 50%;
294293
margin-left: -70px;
295294
right: initial;
295+
z-index: -1;
296296
}
297297
}
298298

docs/get_started/osx_setup.md

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,68 @@ Install the dependencies, required for MXNet, with the following commands:
3939
```
4040
After you have installed the dependencies, use one of the following options to pull the MXNet source code from Git and build MXNet. Both options produce a library called ```libmxnet.so```.
4141

42+
### Prepare Environment for GPU Installation
43+
44+
If you plan to build with GPU, you need to set up environemtn for CUDA and cuDNN.
45+
46+
First download and install [CUDA 8 toolkit](https://developer.nvidia.com/cuda-toolkit).
47+
48+
Once you have the CUDA Toolkit installed you will need to setup the required environment variables by adding the following to your ~/.bash_profile file:
49+
50+
```bash
51+
export CUDA_HOME=/usr/local/cuda
52+
export DYLD_LIBRARY_PATH="$CUDA_HOME/lib:$DYLD_LIBRARY_PATH"
53+
export PATH="$CUDA_HOME/bin:$PATH"
54+
```
55+
56+
Reload ~/.bash_profile file and install dependecies:
57+
```bash
58+
. ~/.bash_profile
59+
brew install coreutils
60+
brew tap caskroom/cask
61+
```
62+
63+
Then download [cuDNN 5](https://developer.nvidia.com/cudnn).
64+
65+
Unzip the file and change to cudnn root directory. Move the header files and libraries to your local CUDA Toolkit folder:
66+
67+
```bash
68+
$ sudo mv include/cudnn.h /Developer/NVIDIA/CUDA-8.0/include/
69+
$ sudo mv lib/libcudnn* /Developer/NVIDIA/CUDA-8.0/lib
70+
$ sudo ln -s /Developer/NVIDIA/CUDA-8.0/lib/libcudnn* /usr/local/cuda/lib/
71+
```
72+
73+
Now we can start to build MXNet.
74+
4275
**Option 1** Use the following commands to pull MXNet source code and build MXNet. 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:
4376

4477
```bash
45-
git clone --recursive https://github.com/dmlc/mxnet
46-
cd mxnet
47-
cp make/osx.mk ./config.mk
48-
echo "USE_BLAS = openblas" >> ./config.mk
49-
echo "ADD_CFLAGS += -I/usr/local/opt/openblas/include" >> ./config.mk
50-
echo "ADD_LDFLAGS += -L/usr/local/opt/openblas/lib" >> ./config.mk
51-
echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk
52-
make -j$(sysctl -n hw.ncpu)
78+
git clone --recursive https://github.com/dmlc/mxnet
79+
cd mxnet
80+
cp make/osx.mk ./config.mk
81+
echo "USE_BLAS = openblas" >> ./config.mk
82+
echo "ADD_CFLAGS += -I/usr/local/opt/openblas/include" >> ./config.mk
83+
echo "ADD_LDFLAGS += -L/usr/local/opt/openblas/lib" >> ./config.mk
84+
echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk
85+
make -j$(sysctl -n hw.ncpu)
86+
```
87+
88+
If building with GPU, add the following configuration to config.mk and build:
89+
```bash
90+
echo "USE_CUDA = 1" >> ./config.mk
91+
echo "USE_CUDA_PATH = /usr/local/cuda" >> ./config.mk
92+
echo "USE_CUDNN = 1" >> ./config.mk
93+
make
5394
```
5495
**Note:** To change build parameters, edit ```config.mk```.
5596

5697
**Option 2**
5798
To generate an [Xcode](https://en.wikipedia.org/wiki/Xcode) project from MXNet source code, use the ```cmake``` command. Then, build MXNet using the Xcode IDE.
5899

59100
```bash
60-
mkdir build; cd build
101+
mkdir build; cd build
61102

62-
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" -DUSE_OPENMP="OFF" -DUSE_CUDNN="OFF" -DUSE_CUDA="OFF" -DBLAS=MKL ..
103+
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" -DUSE_OPENMP="OFF" -DUSE_CUDNN="OFF" -DUSE_CUDA="OFF" -DBLAS=MKL ..
63104
```
64105

65106
After running the ```cmake``` command, use Xcode to open ```mxnet.xcodeproj```, change the following build settings flags, and build the project:
@@ -137,13 +178,13 @@ For OS X (Mac) users, MXNet provides a prebuilt binary package for CPUs. The pre
137178
Run the following commands to install the MXNet dependencies and build the MXNet R package.
138179

139180
```r
140-
Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"
181+
Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"
141182
```
142183
```bash
143-
cd R-package
144-
Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)"
145-
cd ..
146-
make rpkg
184+
cd R-package
185+
Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)"
186+
cd ..
187+
make rpkg
147188
```
148189

149190
**Note:** R-package is a folder in the MXNet source.
@@ -179,15 +220,15 @@ For more details about installing and using MXNet with Julia, see the [MXNet Jul
179220
Before you build MXNet for Scala from source code, you must complete [building the shared library](#build-the-shared-library). After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Scala package:
180221

181222
```bash
182-
make scalapkg
223+
make scalapkg
183224
```
184225

185226
This command creates the JAR files for the assembly, core, and example modules. It also creates the native library in the ```native/{your-architecture}/target directory```, which you can use to cooperate with the core module.
186227

187228
To install the MXNet Scala package into your local Maven repository, run the following command from the MXNet source root directory:
188229

189230
```bash
190-
make scalainstall
231+
make scalainstall
191232
```
192233

193234
## Next Steps

docs/get_started/ubuntu_setup.md

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,62 @@ MXNet currently supports Python, R, Julia, and Scala. For users of Python and R
33

44
The simple installation scripts set up MXNet for Python and R on computers running Ubuntu 12 or later. The scripts install MXNet in your home folder ```~/mxnet```.
55

6+
## Prepare environment for GPU Installation
7+
8+
If you plan to build with GPU, you need to set up environemtn for CUDA and CUDNN.
9+
10+
First download and install [CUDA 8 toolkit](https://developer.nvidia.com/cuda-toolkit).
11+
12+
Then download [cudnn 5](https://developer.nvidia.com/cudnn).
13+
14+
Unzip the file and change to cudnn root directory. Move the header and libraries to your local CUDA Toolkit folder:
15+
16+
```bash
17+
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
18+
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
19+
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
20+
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
21+
sudo ldconfig
22+
```
23+
24+
Finally add configurations to config.mk file:
25+
26+
```bash
27+
cp make/config.mk .
28+
```
29+
630
## Quick Installation
731
### Install MXNet for Python
832

933
To clone the MXNet source code repository to your computer, use ```git```.
1034
```bash
11-
# Install git if not already installed.
12-
sudo apt-get update
13-
sudo apt-get -y install git
35+
# Install git if not already installed.
36+
sudo apt-get update
37+
sudo apt-get -y install git
1438
```
1539

1640
Clone the MXNet source code repository to your computer, run the installation script, and refresh the environment variables. In addition to installing MXNet, the script installs all MXNet dependencies: ```Numpy```, ```LibBLAS``` and ```OpenCV```.
1741
It takes around 5 minutes to complete the installation.
1842

1943
```bash
20-
# Clone mxnet repository. In terminal, run the commands WITHOUT "sudo"
21-
git clone https://github.com/dmlc/mxnet.git ~/mxnet --recursive
22-
23-
# Install MXNet for Python with all required dependencies
24-
cd ~/mxnet/setup-utils
25-
bash install-mxnet-ubuntu-python.sh
26-
27-
# We have added MXNet Python package path in your ~/.bashrc.
28-
# Run the following command to refresh environment variables.
29-
$ source ~/.bashrc
44+
# Clone mxnet repository. In terminal, run the commands WITHOUT "sudo"
45+
git clone https://github.com/dmlc/mxnet.git ~/mxnet --recursive
46+
47+
# If building with GPU, add configurations to config.mk file:
48+
cd ~/mxnet
49+
cp make/config.mk .
50+
echo "USE_CUDA=1" >>config.mk
51+
echo "USE_CUDA_PATH=/usr/local/cuda" >>config.mk
52+
echo "USE_CUDNN=1" >>config.mk
53+
echo "USE_DIST_KVSTORE=1" >>config.mk
54+
55+
# Install MXNet for Python with all required dependencies
56+
cd ~/mxnet/setup-utils
57+
bash install-mxnet-ubuntu-python.sh
58+
59+
# We have added MXNet Python package path in your ~/.bashrc.
60+
# Run the following command to refresh environment variables.
61+
$ source ~/.bashrc
3062
```
3163

3264
You can view the installation script we just used to install MXNet for Python [here](https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-ubuntu-python.sh).
@@ -36,8 +68,8 @@ You can view the installation script we just used to install MXNet for Python [h
3668
To install MXNet for R:
3769

3870
```bash
39-
cd ~/mxnet/setup-utils
40-
bash install-mxnet-ubuntu-r.sh
71+
cd ~/mxnet/setup-utils
72+
bash install-mxnet-ubuntu-r.sh
4173
```
4274
The installation script to install MXNet for R can be found [here](https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-ubuntu-r.sh).
4375

@@ -63,15 +95,30 @@ On Ubuntu versions 13.10 or later, you need the following dependencies:
6395
Install these dependencies using the following commands:
6496

6597
```bash
66-
sudo apt-get update
67-
sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev
98+
sudo apt-get update
99+
sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev
100+
```
101+
102+
After you have downloaded and installed the dependencies, use the following commands to pull the MXNet source code from GitHub
103+
104+
```bash
105+
git clone --recursive https://github.com/dmlc/mxnet
106+
```
107+
108+
If building with GPU, add configurations to config.mk file:
109+
```bash
110+
cd mxnet
111+
cp make/config.mk .
112+
echo "USE_CUDA=1" >>config.mk
113+
echo "USE_CUDA_PATH=/usr/local/cuda" >>config.mk
114+
echo "USE_CUDNN=1" >>config.mk
115+
echo "USE_DIST_KVSTORE=1" >>config.mk
68116
```
69117

70-
After you have downloaded and installed the dependencies, use the following commands to pull the MXNet source code from GitHub and build MXNet:
118+
Then build mxnet:
71119

72120
```bash
73-
git clone --recursive https://github.com/dmlc/mxnet
74-
cd mxnet; make -j$(nproc)
121+
make -j$(nproc)
75122
```
76123

77124
Executing these commands creates a library called ```libmxnet.so```.
@@ -96,41 +143,41 @@ We have installed MXNet core library. Next, we will install MXNet interface pack
96143
Run the following commands to install the MXNet dependencies and build the MXNet R package.
97144

98145
```r
99-
Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"
146+
Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"
100147
```
101148
```bash
102-
cd R-package
103-
Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)"
104-
cd ..
105-
make rpkg
149+
cd R-package
150+
Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)"
151+
cd ..
152+
make rpkg
106153
```
107154

108155
**Note:** R-package is a folder in the MXNet source.
109156

110157
These commands create the MXNet R package as a tar.gz file that you can install as an R package. To install the R package, run the following command, use your MXNet version number:
111158

112159
```bash
113-
R CMD INSTALL mxnet_0.7.tar.gz
160+
R CMD INSTALL mxnet_0.7.tar.gz
114161
```
115162

116163
### Install the MXNet Package for Julia
117164

118165
The MXNet package for Julia is hosted in a separate repository, MXNet.jl, which is available on [GitHub](https://github.com/dmlc/MXNet.jl). To use Julia binding it with an existing libmxnet installation, set the ```MXNET_HOME``` environment variable by running the following command:
119166

120167
```bash
121-
export MXNET_HOME=/<path to>/libmxnet
168+
export MXNET_HOME=/<path to>/libmxnet
122169
```
123170

124171
The path to the existing libmxnet installation should be the root directory of libmxnet. In other words, you should be able to find the ```libmxnet.so``` file at ```$MXNET_HOME/lib```. For example, if the root directory of libmxnet is ```~```, you would run the following command:
125172

126173
```bash
127-
export MXNET_HOME=/~/libmxnet
174+
export MXNET_HOME=/~/libmxnet
128175
```
129176

130177
You might want to add this command to your ```~/.bashrc``` file. If you do, you can install the Julia package in the Julia console using the following command:
131178

132179
```julia
133-
Pkg.add("MXNet")
180+
Pkg.add("MXNet")
134181
```
135182

136183
For more details about installing and using MXNet with Julia, see the [MXNet Julia documentation](http://dmlc.ml/MXNet.jl/latest/user-guide/install/).
@@ -177,15 +224,15 @@ If your native environment differs slightly from the assembly package, for examp
177224
Before you build MXNet for Scala from source code, you must complete [building the shared library](#build-the-shared-library). After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Scala package:
178225

179226
```bash
180-
make scalapkg
227+
make scalapkg
181228
```
182229

183230
This command creates the JAR files for the assembly, core, and example modules. It also creates the native library in the ```native/{your-architecture}/target directory```, which you can use to cooperate with the core module.
184231

185232
To install the MXNet Scala package into your local Maven repository, run the following command from the MXNet source root directory:
186233

187234
```bash
188-
make scalainstall
235+
make scalainstall
189236
```
190237

191238
**Note - ** You are more than welcome to contribute easy installation scripts for other operating systems and programming languages, see [community page](http://mxnet.io/community/index.html) for contributors guidelines.

0 commit comments

Comments
 (0)