"tests/vscode:/vscode.git/clone" did not exist on "cd3bbe2910666880307b84729176203f5785ff7e"
index.rst 4.57 KB
Newer Older
Minjie Wang's avatar
Minjie Wang committed
1
2
3
Install DGL
============

Gan Quan's avatar
Gan Quan committed
4
At this stage, we recommend installing DGL from ``conda`` or ``pip``.
Minjie Wang's avatar
Minjie Wang committed
5

Gan Quan's avatar
Gan Quan committed
6
7
8
9
10
11
System requirements
-------------------
Currently DGL is tested on

* Ubuntu 16.04
* macOS X
12
* Windows 10
Gan Quan's avatar
Gan Quan committed
13
14

DGL is expected to work on all Linux distributions later than Ubuntu 16.04, macOS X, and
15
Windows 10.
Gan Quan's avatar
Gan Quan committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

DGL also requires the Python version to be 3.5 or later.  Python 3.4 or less is not
tested, and Python 2 support is coming.

DGL supports multiple tensor libraries (e.g. PyTorch, MXNet) as backends; refer
`Working with different backends`_ for requirements on backends and how to select a
backend.

Install from conda
----------------------
One can either grab `miniconda <https://conda.io/miniconda.html>`_ or
the full `anaconda <https://www.anaconda.com/download/>`_ if ``conda``
has not been installed.

Once the conda environment is activated, run
Minjie Wang's avatar
Minjie Wang committed
31
32
33

.. code:: bash

Gan Quan's avatar
Gan Quan committed
34
   conda install -c dglteam dgl
Minjie Wang's avatar
Minjie Wang committed
35

Gan Quan's avatar
Gan Quan committed
36
37
38
Install from pip
----------------
One can simply run the following command to install via ``pip``:
Minjie Wang's avatar
Minjie Wang committed
39
40
41

.. code:: bash

Gan Quan's avatar
Gan Quan committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
   pip install dgl

Working with different backends
-------------------------------

Currently DGL supports PyTorch and MXNet.

Switching backend
`````````````````

The backend is controlled by ``DGLBACKEND`` environment variable, which defaults to
``pytorch``.  Currently it supports the following values:

+---------+---------+--------------------------------------------------+
| Value   | Backend | Memo                                             |
+=========+=========+==================================================+
| pytorch | PyTorch | Requires 0.4.1 or later; see                     |
|         |         | `official website <https://pytorch.org>`_        |
+---------+---------+--------------------------------------------------+
| mxnet   | MXNet   | Requires nightly build; run the following        |
62
|         |         | command to install:                              |
Gan Quan's avatar
Gan Quan committed
63
64
65
66
67
68
69
70
|         |         |                                                  |
|         |         | .. code:: bash                                   |
|         |         |                                                  |
|         |         |    pip install --pre mxnet                       |
+---------+---------+--------------------------------------------------+
| numpy   | NumPy   | Does not support gradient computation            |
+---------+---------+--------------------------------------------------+

71
72
.. _install-from-source:

Gan Quan's avatar
Gan Quan committed
73
74
75
76
77
Install from source
-------------------
First, download the source files from GitHub:

.. code:: bash
Minjie Wang's avatar
Minjie Wang committed
78

Haibin Lin's avatar
Haibin Lin committed
79
   git clone --recursive https://github.com/dmlc/dgl.git
Minjie Wang's avatar
Minjie Wang committed
80

Gan Quan's avatar
Gan Quan committed
81
One can also clone the repository first and run the following:
Minjie Wang's avatar
Minjie Wang committed
82
83
84

.. code:: bash

Gan Quan's avatar
Gan Quan committed
85
86
87
88
89
   git submodule init
   git submodule update

Linux
`````
Minjie Wang's avatar
Minjie Wang committed
90

Gan Quan's avatar
Gan Quan committed
91
92
Install the system packages for building the shared library, for Debian/Ubuntu
users, run:
Minjie Wang's avatar
Minjie Wang committed
93
94
95

.. code:: bash

Gan Quan's avatar
Gan Quan committed
96
97
   sudo apt-get update
   sudo apt-get install -y build-essential build-dep python3-dev make cmake
Minjie Wang's avatar
Minjie Wang committed
98

Gan Quan's avatar
Gan Quan committed
99
For Fedora/RHEL/CentOS users, run:
Minjie Wang's avatar
Minjie Wang committed
100

Gan Quan's avatar
Gan Quan committed
101
102
103
.. code:: bash

   sudo yum install -y gcc-c++ python3-devel make cmake
Minjie Wang's avatar
Minjie Wang committed
104

Gan Quan's avatar
Gan Quan committed
105
Build the shared library and install the Python binding afterwards:
Minjie Wang's avatar
Minjie Wang committed
106
107
108

.. code:: bash

Gan Quan's avatar
Gan Quan committed
109
110
111
112
113
114
115
116
117
118
119
120
   mkdir build
   cd build
   cmake ..
   make -j4
   cd ../python
   python setup.py install

macOS
`````

Installation on macOS is similar to Linux. But macOS users need to install
building tools like clang, GNU Make, cmake first.
Minjie Wang's avatar
Minjie Wang committed
121

Gan Quan's avatar
Gan Quan committed
122
123
Tools like clang and GNU Make are packaged in **Command Line Tools** for macOS. To
install:
Minjie Wang's avatar
Minjie Wang committed
124
125
126

.. code:: bash

Gan Quan's avatar
Gan Quan committed
127
   xcode-select --install
Minjie Wang's avatar
Minjie Wang committed
128

Gan Quan's avatar
Gan Quan committed
129
130
131
132
133
To install other needed packages like cmake, we recommend first installing
**Homebrew**, which is a popular package manager for macOS. Detailed
instructions can be found on its `homepage <https://brew.sh/>`_.

After installation of Homebrew, install cmake by:
Minjie Wang's avatar
Minjie Wang committed
134
135
136

.. code:: bash

Gan Quan's avatar
Gan Quan committed
137
   brew install cmake
Minjie Wang's avatar
Minjie Wang committed
138

Gan Quan's avatar
Gan Quan committed
139
140
141
142
Then go to root directory of DGL repository, build shared library and
install Python binding for DGL:

.. code:: bash
Minjie Wang's avatar
Minjie Wang committed
143

Gan Quan's avatar
Gan Quan committed
144
145
146
147
148
149
   mkdir build
   cd build
   cmake ..
   make -j4
   cd ../python
   python setup.py install
Minjie Wang's avatar
Minjie Wang committed
150

Gan Quan's avatar
Gan Quan committed
151
152
We tested installation on macOS X with clang 10.0.0, GNU Make 3.81, and cmake
3.13.1.
Minjie Wang's avatar
Minjie Wang committed
153

Gan Quan's avatar
Gan Quan committed
154
155
Windows
```````
Minjie Wang's avatar
Minjie Wang committed
156

Gan Quan's avatar
Gan Quan committed
157
158
159
Currently Windows source build is tested with CMake and MinGW/GCC.  We highly recommend
using CMake and GCC from `conda installations <https://conda.io/miniconda.html>`_.  To
do so, run
Minjie Wang's avatar
Minjie Wang committed
160
161
162

.. code:: bash

Gan Quan's avatar
Gan Quan committed
163
164
165
166
167
168
169
170
   conda install cmake m2w64-gcc m2w64-make

Then build the shared library and install the Python binding:

.. code::

   md build
   cd build
171
   cmake -DCMAKE_CXX_FLAGS="-DDMLC_LOG_STACK_TRACE=0 -DDGL_EXPORTS" -DCMAKE_MAKE_PROGRAM=mingw32-make .. -G "MSYS Makefiles"
Gan Quan's avatar
Gan Quan committed
172
173
174
   mingw32-make
   cd ..\python
   python setup.py install