README.md 3.51 KB
Newer Older
Paul's avatar
Paul committed
1
# AMD MIGraphX
Paul's avatar
Paul committed
2

Paul's avatar
Paul committed
3
AMD's graph optimization engine.
Paul's avatar
Paul committed
4
5
6
7
8

## Prerequisites
* [ROCm cmake modules](https://github.com/RadeonOpenCompute/rocm-cmake) **required**
* [MIOpen](https://github.com/ROCmSoftwarePlatform/MIOpen) for running on the GPU
* [HIP](https://github.com/ROCm-Developer-Tools/HIP) for running on the GPU
9
* [Protobuf](https://github.com/google/protobuf) for reading [onnx](https://github.com/onnx/onnx) files
Paul's avatar
Paul committed
10
* [Half](http://half.sourceforge.net/) - IEEE 754-based half-precision floating point library
Paul's avatar
Paul committed
11
* [pybind11](https://pybind11.readthedocs.io/en/stable/) - for python bindings
Paul's avatar
Paul committed
12
13
14

## Installing the dependencies

15
Dependencies can be installed using the ROCm build tool [rbuild](https://github.com/RadeonOpenCompute/rbuild).
Paul's avatar
Paul committed
16

17
To install rbuild:
Paul's avatar
Paul committed
18
```
19
pip install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
Paul's avatar
Paul committed
20
21
```

22
23
To build dependencies along with MIGraphX
```
Paul Fultz II's avatar
Paul Fultz II committed
24
rbuild build -d depend --cxx=/opt/rocm/llvm/bin/clang++
25
26
```
This builds dependencies in the subdirectory named depend and then builds MIGraphX using these dependencies.
Paul's avatar
Paul committed
27

Paul's avatar
Paul committed
28
## Building MIGraphX from source
Paul's avatar
Paul committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

## Configuring with cmake

First create a build directory:


```
mkdir build; 
cd build;
```

Next configure cmake. The hcc compiler is required to build the MIOpen backend:


```
Paul Fultz II's avatar
Paul Fultz II committed
44
CXX=/opt/rocm/llvm/bin/clang++ cmake ..
Paul's avatar
Paul committed
45
46
47
48
49
50
```

If the dependencies from `install_deps.cmake` was installed to another directory, the `CMAKE_PREFIX_PATH` needs to be set to what `--prefix` was set to from `install_deps.cmake`:


```
Paul Fultz II's avatar
Paul Fultz II committed
51
CXX=/opt/rocm/llvm/bin/clang++ cmake -DCMAKE_PREFIX_PATH=/some/dir ..
Paul's avatar
Paul committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
```


#### Changing the cmake configuration

The configuration can be changed after running cmake by using `ccmake`:

` ccmake .. ` **OR** `cmake-gui`: ` cmake-gui ..`

## Building the library

The library can be built, from the `build` directory using the 'Release' configuration:

` cmake --build . --config Release ` **OR** ` make `

And can be installed by using the 'install' target:

` cmake --build . --config Release --target install ` **OR** ` make install `

71
72
73
74
75
This will install the library to the `CMAKE_INSTALL_PREFIX` path that was set.

To build a debug version of the library, the cmake variable `CMAKE_BUILD_TYPE` can be set to `Debug`.

` cmake -DCMAKE_BUILD_TYPE=Debug . `
Paul's avatar
Paul committed
76
77
78
79
80
81
82

## Running the tests

The tests can be run by using the 'check' target:

` cmake --build . --config Release --target check ` **OR** ` make check `

Paul's avatar
Paul committed
83
84
85
86
87
88
## Building the documentation

HTML and PDF documentation can be built using:

`cmake --build . --config Release --target doc` **OR** `make doc`

Paul's avatar
Paul committed
89
90
91
92
93
94
95
96
97
98
This will build a local searchable web site inside the doc/html folder.

Documentation is built using [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html), [Sphinx](http://www.sphinx-doc.org/en/stable/index.html), and [Breathe](https://breathe.readthedocs.io/en/latest/)

Requirements for both Sphinx and Breathe can be installed with:

`pip install -r doc/requirements.txt`

Depending on your setup `sudo` may be required for the pip install.

Paul's avatar
Paul committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
## Formatting the code

All the code is formatted using clang-format. To format a file, use:

```
clang-format-5.0 -style=file -i <path-to-source-file>
```

Also, githooks can be installed to format the code per-commit:

```
./.githooks/install
```

## Using docker

The easiest way to setup the development environment is to use docker. You can build the top-level docker file:

Paul's avatar
Paul committed
117
    docker build -t migraphx .
Paul's avatar
Paul committed
118
119
120

Then to enter the developement environment use `docker run`:

Paul's avatar
Paul committed
121
    docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/data -w /data --group-add video -it migraphx