-
Notifications
You must be signed in to change notification settings - Fork 85
Build MIGraphX Source in ROCm3.3
Build MIGraphX source in ROCm3.3 is very similar as that in ROCm3.7 as described in the MIGraphX repository
webpage. The only difference is that the compiler in ROCm3.3 is hcc
rather
than the clang++
in ROCm3.7 or later releases.
They are three ways to build MIGraphX source in ROCm3.3, the first one is using the ROCm build tool rbuild with only one command. The second approach is building the prerequisites, configuring cmake, and building the source code, and the last approach is using a docker image to set up the development environment, then build MIGraphX source code inside the docker container.
Use the ROCm build tool rbuild.
In this approach, we use the rbuild build tool to build MIGraphX. The specific steps are as follows:
- Install rocm-cmake, pip3, rocblas, and with the command
sudo apt update && sudo apt install -y rocm-cmake python3-pip rocblas
Note that we do not install the miopen-hip
package since the MIOpen contained in ROCm3.3 is out of date. We will install MIOpen through the rbuild command in step 3).
- Install rbuild (sudo may be required here.)
pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
- Build MIGraphX source code
rbuild build -d depend -B build --cxx=/opt/rocm/bin/hcc
then all the prerequisites are in the folder depend
, and MIGraphX is built in the build
directory. Again, the difference is the compiler used here.
The prerequisites required to build MIGraphX source are the same as that in ROCm3.6 and are listed here. They can be installed with three approaches (you can choose anyone from them):
- Use the rbuild command
The steps here is the same as in the previous section. After running the rbuild command, all the prerequisites are in the folder depend
.
- Use a script install_prereqs_rocm3.3.sh
You can download a script install_prereqs_rocm3.3.sh and copy it to the location as
$migraphx_dir/tools/install_prereqs_rocm3.3.sh
, then run the command ./tools/install_prereqs_rocm3.3.sh
.
By default, all prerequisites are installed at the default location /usr/local
and are accessible by all users. For the default
location, sudo
is required to run the script. You can also specify a location at which the prerequisites are installed using
the command ./tools/install_prereqs_rocm3.3.sh $your_loc
.)
- Use a docker container We provide a docker file hcc.docker that can be used to build a docker image with all the prerequisites installed.
You can download this docker file and copy it to the project folder, then run the following command to build a docker image.
docker build -t migraphx:rocm3.3 -f hcc.docker .
To enter the developement environment use docker run
:
docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/code/AMDMIGraphX -w /code/AMDMIGraphX --group-add video -it migraphx:rocm3.3
In the docker container, all the required prerequisites are already installed, so users can just go to the folder
/code/AMDMIGraphX
and follow the steps in the next section to build MIGraphX source.
With the prerequisites installed successfully, MIGraphX source code can be built as:
- Go to the project folder and create a
build
directory:
mkdir build
cd build
- Configure the cmake. If the prerequisites are installed at the default location
/usr/local
, the command is:
CXX=/opt/rocm/bin/hcc cmake ..
Otherwise, you need to set -DCMAKE_PREFIX_PATH=$your_loc
to configure the cmake as:
CXX=/opt/rocm/bin/hcc cmake -DCMAKE_PREFIX_PATH=$your_loc ..
- Build MIGraphX source code
make -j$(nproc)
Correctness can be verified as:
make -j$(nproc) check
Finally, MIGraphX libs can be installed as:
make install
Note that the only different from building the source in ROCm3.7 is that the compiler is hcc
here.