Explore GPU

Sanity Check #1:

Run Standard nvidia-smi Tool


In [ ]:
%%bash 

nvidia-smi

Sanity Check #2:

Run Accelerated Linear Algebra (XLA) Tests


In [ ]:
%%bash 

xla_device_test &> xla_device_test.log

tail -3 xla_device_test.log

Run Some CUDA Code!

Show CUDA Code


In [ ]:
%%bash 

cat /root/src/main/cuda/SumArrays.cu

Run CUDA Code and Verify Expected Output

### EXPECTED OUTPUT ###
...
*** Awesome!  The GPU summed the arrays!! ***
...

Note the execution time.


In [ ]:
%%bash 

sum_arrays

Open a Terminal through Jupyter Notebook

(Menu Bar -> Terminal -> New Terminal)

Run this Command to Watch GPU Every Second:

watch -n 1 nvidia-smi

Run Code In Loop, Watch GPU

Note: Don't go higher than 10!

Otherwise the following may happen:

  • this cell will take a long time to finish
  • you may kill your instance!!

In [ ]:
%%bash

# Don't go above 10!!
for _ in {1..10}
do
  sum_arrays > /dev/null 2>&1
done

echo "...Done!"

Run Some Advanced CUDA Code!

We lower overall execution time using async, stream-based memcpy

Show Advanced CUDA Code, Find Stream


In [ ]:
%%bash 

cat /root/src/main/cuda/SumArraysAsyncMemcpy.cu

Run CUDA Code and Verify Expected Output

### EXPECTED OUTPUT ###
...
*** Awesome!  The GPU summed the arrays!! ***
...

Also, note the lower execution time due to async memcpy.


In [ ]:
%%bash 

sum_arrays_async_memcpy

In [ ]:
%%bash

# Don't go above 10!!
for _ in {1..10}
do
  sum_arrays_async_memcpy > /dev/null 2>&1
done

echo "...Done!"

In [ ]: