DEV Community

عبدالله عياد | Abdullah Ayad for AWS Community Builders

Posted on • Updated on

An experiment comparing the performance of computations on CPUs and a GPU

Introduction

  • The CPU versus GPU performance experiment is set up. In this Lab Step, you will run the experiment.
  • You will monitor the CPU and GPU devices while the experiment is being performed
  • Before to read this post, you have to see my previous post from here

Perform the experiement

Step 1

In your Jupyter notebook, click the Run button to start running the experiment:

Image description

  • The code will start running. It will take around 30 seconds before you see any output.
  • The first time you run the cell it takes significantly longer than following times because the code is being compiled and libraries are being loaded, and the code is loaded onto the GPU.
  • The first output you see will be warning messages:

Image description

The warnings don't impact the results of the experiment and can be ignored.

Step 2

Once you see Calculating 100x100 matrix product, pay attention to changes in the CPU and GPU statistics.

The CPU statistics indicate that all four cores are being utilized to their full ability:

Image description

  • A %CPU value of 400 indicates all four cores are being utilized 100% each.
  • Having all CPUs fully utilized indicates that the performance of the computation is limited by the number of CPUs.
  • That is, more CPUs are needed to perform better. This state is referred to as being compute-bound.
  • On the other hand, the GPU never seems to reach 100% utilization (GPU-Util):

Image description

  • This indicates that the GPU has more capacity before the GPU becomes compute-bound.
  • Other changes you will notice is the addition of a python process in the lower Processes table.
  • The temperature of the GPU increases quite sharply when the computations first start before plateauing.
  • The power fluctuates from a standy level to an elevated level when the GPU is performing a computation.

Step 3

-When the experiment completes, observe the two charts displayed in the notebook.

  • You will analyze the results in the next Lab Step.

Step 4

  • Re-select the cell with the Python code in it, and run it again.
  • Watch for any differences in GPU and CPU metrics that you might have missed the first time.



You can see the analysis of this experiment from here




GitHub
LinkedIn
Facebook
Medium

Oldest comments (0)