Coder Social home page Coder Social logo

nbolade-224 / amdmigraphx-fork Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rocm/amdmigraphx

0.0 0.0 0.0 17.22 MB

AMD's graph optimization engine.

Home Page: https://rocm.docs.amd.com/projects/AMDMIGraphX/en/latest/

License: MIT License

Shell 0.12% C++ 90.97% Python 7.36% C 0.35% PureBasic 0.03% CMake 1.10% Dockerfile 0.07% Vim Script 0.01%

amdmigraphx-fork's Introduction

AMD MIGraphX

AMD MIGraphX is AMD's graph inference engine, which accelerates machine learning model inference. To use MIGraphX, you can install the binaries or build from source code. Refer to the following sections for Ubuntu installation instructions (we'll provide instructions for other Linux distributions in the future).

Note

You must install ROCm before installing MIGraphX.

Installing from binaries

Install binaries using:

sudo apt update && sudo apt install -y migraphx

Header files and libraries are installed under /opt/rocm-<version>, where <version> is the ROCm version.

Building from source

You have three options for building from source:

  • ROCm build tool: Uses rbuild to install prerequisites, then you can build the libraries with a single command.

  • CMake: Uses a script to install prerequisites, then you can use CMake to build the source.

  • Docker: Builds a Docker image with all prerequisites installed, then you can build the MIGraphX sources inside a Docker container.

Build prerequisites

The following is a list of prerequisites for building MIGraphX.

  • ROCm CMake modules required
  • MIOpen for running on the GPU
  • rocBLAS for running on the GPU
  • HIP for running on the GPU
  • Protobuf for reading onnx files
  • Half, an IEEE 754-based half-precision floating point library
  • pybind11 for python bindings
  • JSON for model serialization to json string format
  • MessagePack for model serialization to binary format
  • SQLite3 to create database of kernels' tuning information or run queries on existing database

Use the ROCm build tool rbuild.

  1. Install rocm-cmake, pip3, rocblas, and miopen-hip:

    sudo apt install -y rocm-cmake python3-pip rocblas miopen-hip
  2. Install rbuild (sudo may be required):

    pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
  3. Build MIGraphX source code:

    rbuild build -d depend -B build -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')

Once completed, all prerequisites are in the depend folder and MIGraphX is in the build directory.

Note

If you get an rbuild: command not found error, it's because rbuild is installed in $HOME/.local/bin, which is not in PATH. You can either export PATH as export PATH=$HOME/.local/bin:$PATH to add the folder to PATH, or add the option --prefix /usr/local in the pip3 command when installing rbuild.

Use CMake to build MIGraphX

  1. Install the prerequisites:

    rbuild prepare -d depend

    This puts all the prerequisites are in depend the folder. They can be used in the cmake configuration as -DCMAKE_PREFIX_PATH=depend.

    If you have sudo access, as an alternative to the rbuild command, you can install the prerequisites in the same way as a Dockerfile, by calling ./tools/install_prereqs.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 different location using ./tools/install_prereqs.sh $custom_location.

  2. Go to the project folder and create a build directory:

    mkdir build
    cd build
  3. Configure CMake. If the prerequisites are installed at the default location /usr/local, use:

    CXX=/opt/rocm/llvm/bin/clang++ cmake .. -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')

    Otherwise, you need to set -DCMAKE_PREFIX_PATH=$your_loc to configure CMake.

  4. Build MIGraphX source code:

    make -j$(nproc)

    You can verify this using:

    make -j$(nproc) check
  5. Install MIGraphX libraries:

    make install

Use Docker

The easiest way to set up the development environment is to use Docker.

  1. With the Dockerfile, build a Docker image:

        docker build -t migraphx .
  2. Enter the development environment using docker run:

        docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/code/AMDMIGraphX -w /code/AMDMIGraphX --group-add video -it migraphx
  3. In the Docker container, all required prerequisites are already installed, so you can go to the folder /code/AMDMIGraphX and follow the steps (starting from 2) in the Use CMake to build MIGraphX.

Using the MIGraphX Python module

To use MIGraphX's Python module, you can set PYTHONPATH or use the .deb package:

  • Setting PYTHONPATH:

    export PYTHONPATH=/opt/rocm/lib:$PYTHONPATH
  • Creating the deb package:

    make package

    This provides the path for .deb package.

    To install:

    dpkg -i <path_to_deb_file>

Calling MIGraphX APIs

To use MIGraphX's C/C++ API in your CMake project, you must set CMAKE_PREFIX_PATH to the MIGraphX installation location and run:

find_package(migraphx)
target_link_libraries(myApp migraphx::c)

Where myApp is the CMake target in your project.

Building for development

Using rbuild, you can install the dependencies for development with:

rbuild develop -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')

This installs development dependencies in the deps directory and configures cmake to use those dependencies in the build directory. You can change these directories by passing the --deps-dir and --build-dir flags to the rbuild command:

rbuild develop --build-dir build_rocm_55 --deps-dir /home/user/deps_dir

Building the documentation

HTML and PDF documentation can be built using:

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

This will build a local searchable web site inside the docs/html folder.

Documentation is built using Doxygen and rocm-docs-core

Run the steps below to build documentation locally.

cd docs

pip3 install -r sphinx/requirements.txt

python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html

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

Formatting the code

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

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

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

./.githooks/install

amdmigraphx-fork's People

Contributors

pfultz2 avatar scxiao avatar kahmed10 avatar wsttiger avatar umangyadav avatar mvermeulen avatar charliel7 avatar causten avatar dependabot[bot] avatar mei-ye avatar apwojcik avatar tedthemistokleous avatar github-actions[bot] avatar turneram avatar shivadbhavsar avatar bpickrel avatar ahsan-ca avatar cagery avatar gyulaz-htec avatar attila-dusnoki-htec avatar lakhinderwalia avatar krzysz00 avatar nives-vukovic avatar tvukovic-amd avatar igormirosavljevichtec avatar manupak avatar jerryyin avatar ravil-mobile avatar aaronenyeshi avatar mirza-halilcevic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.