Playing with CUDA and GPUs in Google Colab.
!git clone https://github.com/alessandrobessi/cuda-lab.git
!chmod 755 cuda-lab/INSTALL.sh
!./cuda-lab/INSTALL.sh
/usr/local/cuda/bin
to PATH
:import os
os.environ['PATH'] += ':/usr/local/cuda/bin'
!nvcc cuda-lab/add.cu -o add -Wno-deprecated-gpu-targets
!nvprof ./add
!time ./add
You can also create a Cuda source file using the magic command %%writefile <filename.cu>
:
%%writefile snippet.cu
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
...
and then compile and run it!
!nvcc snippet.cu -o snippet -Wno-deprecated-gpu-targets
!nvprof ./snippet