Skip to content
Caleb Callaway edited this page Oct 4, 2019 · 19 revisions

Please modify this document if you hit any difficulties following it.

Prep

These instructions describe building and installing gputop to ~/local/gputop (in your home directory) and assume that your PATH and LD_LIBRARY_PATH environment variables are configured to run things from this path. If you don't already have a method for managing separate install prefixes of projects, you can create a ~/local/bashrc file:

export PATH=~/local/bin:$PATH
export LD_LIBRARY_PATH=~/local/lib:$LD_LIBRARY_PATH

and source the in your current shell with:

source ~/local/bashrc

or

. ~/local/bashrc

GPUTop uses the meson build system. On a recent distribution you can install meson with :

sudo apt-get install meson

Alternatively you can use the pip distribution mechanism :

sudo apt install python3-pip && sudo pip3 install meson

GPUTop has minimal dependencies :

sudo apt-get install libssl-dev python-mako

If you want to build the UI, also install the following dependencies :

sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev libglfw3-dev libepoxy-dev

Building the Driver:

Some parts of the GPUTop UI rely on 'i915 perf' features that are not yet upstream. To enable all of the features built into the UI, should checkout the kernel from https://github.com/djdeath/linux and build the wip/djdeath/oa-next branch.

Otherwise a stable kernel 4.13+ will give basic functionalities. A kernel 4.15+ will give the ability to list processes.

Building GPU Top

Checkout and configure:

git clone https://github.com/rib/gputop
cd gputop
meson . build

If you also want to build the GPUTop UI run:

meson . build -Dnative_ui=true

Finally, build and install gputop:

ninja -C build
ninja -C build install

Running GPU Top

Running gputop without any options should result in a server listening on port 7890 by default.

Also check gputop --help in case there are new things not mentioned here.

Notably gputop is just a convenience for setting various environment variables before running some other command you are interested in profiling. Running gputop [OPTIONS...] --dry-run will show what's done under the hood and show how the equivalent environment can be setup if you need to run under gdb or valgrind.

Once the gputop server is running then there are a number of clients that can be used to connect and visualize the available metrics.

It is recommended to run GPUTop as root.

Connecting the Web UI

Assuming the web UI hasn't been built so far it's still possible to connect to the gputop server using the UI hosted on github by browsing to https://gputop.com?remoteHost=127.0.0.1&remotePort=7890.

If the web UI has been built then instead browse to http://localhost:7890

CSV output

gputop-wrapper is a tool that can connect to the gputop server and log metrics in a CSV output format. For example run as:

gputop-wrapper -m RenderBasic -c Timestamp,EuActive -o eu-active-log.csv

See gputop-wrapper --help for more details. Running gputop-wrapper without arguments tries to help you discover what metrics are available and gputop -m RenderBasic can explicitly query the available metric sets and counters.

Building the Web UI

The process of building the Web UI is similar to a normal build. It just requires to install the emscripten compiler.

Emscripten

cd /opt && curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | tar xvz
cd /opt/emsdk-portable && ./emsdk install sdk-1.37.27-64bit
chmod go+rX -R /opt/emsdk-portable

Re-building gputop

meson . build-webui -Dwebui=true --cross=scripts/meson-cross/emscripten-docker-debug.txt
ninja -C build-webui

Then copy the generated files :

cp build-webui/gputop-ui/* gputop-ui/

Finally you can serve the UI from the gputop-ui directory with a web server of your choice.