Repository for all things CUDA.
CUDA can be run on the BU Shared Computing Cluster or through Google Colab.
- Login to an scc node.
- Execute the command:
module load cuda/11.3
to load the NVIDIA sdk tools. - To compile your cuda code, execute the command:
nvcc <filename> -o <outfile>
- To run the executable, you need a GPU node. interactive/batch
- Create a new colab notebook.
- Change runtime to GPU.
- Run the following commands to load the CUDA compiler to run CUDA C++ code with Jupyter Notebook.
!python --version
!nvcc --version
!pip install nvcc4jupyter
%load_ext nvcc4jupyter
- Run code by specifying
%%cuda
at beginning of the block followed by your C++ code.
#include <stdio.h>
__global__ void hello(){
printf("Hello from block: %u, thread: %u\n", blockIdx.x, threadIdx.x);
}
int main(){
// numBlocks, numThreadsPerBlock
hello<<<4, 4>>>();
cudaDeviceSynchronize();
}