index.rst 4.01 KB
Newer Older
Minjie Wang's avatar
Minjie Wang committed
1
Install DGL
2
===========
Minjie Wang's avatar
Minjie Wang committed
3

4
This topic explains how to install DGL. We recommend installing DGL by using ``conda`` or ``pip``.
Minjie Wang's avatar
Minjie Wang committed
5

Gan Quan's avatar
Gan Quan committed
6
7
System requirements
-------------------
8
DGL works with the following operating systems:
Gan Quan's avatar
Gan Quan committed
9
10
11

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

14
DGL requires Python version 3.6, 3.7, 3.8 or 3.9.
Gan Quan's avatar
Gan Quan committed
15

16
DGL supports multiple tensor libraries as backends, e.g., PyTorch, MXNet. For requirements on backends and how to select one, see :ref:`backends`.
Gan Quan's avatar
Gan Quan committed
17

18
19
20
Starting at version 0.3, DGL is separated into CPU and CUDA builds.  The builds share the
same Python package name. If you install DGL with a CUDA 9 build after you install the
CPU build, then the CPU build is overwritten.
21

Minjie Wang's avatar
Minjie Wang committed
22
23
Install from Conda or Pip
-------------------------
24

Minjie Wang's avatar
Minjie Wang committed
25
Check out the `Get Started page <https://www.dgl.ai/pages/start.html>`_.
Gan Quan's avatar
Gan Quan committed
26

27
28
.. _install-from-source:

Gan Quan's avatar
Gan Quan committed
29
30
Install from source
-------------------
31
Download the source files from GitHub.
Gan Quan's avatar
Gan Quan committed
32
33

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

35
   git clone --recurse-submodules https://github.com/dmlc/dgl.git
Minjie Wang's avatar
Minjie Wang committed
36

37
(Optional) Clone the repository first, and then run the following:
Minjie Wang's avatar
Minjie Wang committed
38
39
40

.. code:: bash

41
   git submodule update --init --recursive
Gan Quan's avatar
Gan Quan committed
42
43
44

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

46
Install the system packages for building the shared library. For Debian and Ubuntu
Gan Quan's avatar
Gan Quan committed
47
users, run:
Minjie Wang's avatar
Minjie Wang committed
48
49
50

.. code:: bash

Gan Quan's avatar
Gan Quan committed
51
   sudo apt-get update
Da Zheng's avatar
Da Zheng committed
52
   sudo apt-get install -y build-essential python3-dev make cmake
Minjie Wang's avatar
Minjie Wang committed
53

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

Gan Quan's avatar
Gan Quan committed
56
57
58
.. code:: bash

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

60
61
62
Build the shared library. Use the configuration template ``cmake/config.cmake``.
Copy it to either the project directory or the build directory and change the
configuration as you wish. For example, change ``USE_CUDA`` to ``ON`` will
63
enable a CUDA build. You could also pass ``-DKEY=VALUE`` to the cmake command
64
65
for the same purpose.

66
- CPU-only build
67
68
69
70
71
72
   .. code:: bash

      mkdir build
      cd build
      cmake ..
      make -j4
73
- CUDA build
74
75
76
77
78
79
80
81
   .. code:: bash

      mkdir build
      cd build
      cmake -DUSE_CUDA=ON ..
      make -j4

Finally, install the Python binding.
Minjie Wang's avatar
Minjie Wang committed
82
83
84

.. code:: bash

Gan Quan's avatar
Gan Quan committed
85
86
87
88
89
90
   cd ../python
   python setup.py install

macOS
`````

91
Installation on macOS is similar to Linux. But macOS users need to install build tools like clang, GNU Make, and cmake first. These installation steps were tested on macOS X with clang 10.0.0, GNU Make 3.81, and cmake 3.13.1.
Minjie Wang's avatar
Minjie Wang committed
92

Gan Quan's avatar
Gan Quan committed
93
Tools like clang and GNU Make are packaged in **Command Line Tools** for macOS. To
94
install, run the following:
Minjie Wang's avatar
Minjie Wang committed
95
96
97

.. code:: bash

Gan Quan's avatar
Gan Quan committed
98
   xcode-select --install
Minjie Wang's avatar
Minjie Wang committed
99

Gan Quan's avatar
Gan Quan committed
100
To install other needed packages like cmake, we recommend first installing
101
**Homebrew**, which is a popular package manager for macOS. To learn more, see the `Homebrew website <https://brew.sh/>`_.
Gan Quan's avatar
Gan Quan committed
102

103
After you install Homebrew, install cmake.
Minjie Wang's avatar
Minjie Wang committed
104
105
106

.. code:: bash

Gan Quan's avatar
Gan Quan committed
107
   brew install cmake
Minjie Wang's avatar
Minjie Wang committed
108

109
110
Go to root directory of the DGL repository, build a shared library, and
install the Python binding for DGL.
Gan Quan's avatar
Gan Quan committed
111
112

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

Gan Quan's avatar
Gan Quan committed
114
115
   mkdir build
   cd build
116
   cmake -DUSE_OPENMP=off -DCMAKE_C_FLAGS='-DXBYAK_DONT_USE_MAP_JIT' -DCMAKE_CXX_FLAGS='-DXBYAK_DONT_USE_MAP_JIT' ..
Gan Quan's avatar
Gan Quan committed
117
118
119
   make -j4
   cd ../python
   python setup.py install
Minjie Wang's avatar
Minjie Wang committed
120

Gan Quan's avatar
Gan Quan committed
121
122
Windows
```````
Minjie Wang's avatar
Minjie Wang committed
123

124
125
126
You can build DGL with MSBuild.  With `MS Build Tools <https://go.microsoft.com/fwlink/?linkid=840931>`_
and `CMake on Windows <https://cmake.org/download/>`_ installed, run the following
in VS2019 x64 Native tools command prompt.
Gan Quan's avatar
Gan Quan committed
127

128
129
- CPU only build
  .. code::
Gan Quan's avatar
Gan Quan committed
130

131
132
133
134
135
136
137
138
     MD build
     CD build
     cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DCMAKE_CONFIGURATION_TYPES="Release" -DDMLC_FORCE_SHARED_CRT=ON .. -G "Visual Studio 16 2019"
     msbuild dgl.sln /m
     CD ..\python
     python setup.py install
- CUDA build
  .. code::
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
139

140
141
142
143
144
145
     MD build
     CD build
     cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DCMAKE_CONFIGURATION_TYPES="Release" -DDMLC_FORCE_SHARED_CRT=ON -DUSE_CUDA=ON .. -G "Visual Studio 16 2019"
     msbuild dgl.sln /m
     CD ..\python
     python setup.py install
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
146

147
148
Optional Flags
``````````````
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
149

150
151
152
- If you are using PyTorch, you can add ``-DBUILD_TORCH=ON`` flag in CMake
  to build PyTorch plugins for further performance optimization.  This applies for Linux,
  Windows, and Mac.