;

If you are learning High-Performance Computing(HPC), you might have come across Compute Unified Device Architecture(CUDA). CUDA is a proprietary technology developed by Nvidia Corporation for GPU computing. To use the CUDA framework for programming you need to have access to CUDA capable Nvidia GPU. If you do not have access to such GPU, you either have to rent such GPU on cloud platforms like Azure, AWS, and Google cloud or you can use free services like Google Colaboratory to run your CUDA C/C++ programs.  In this article, we will show simple steps to run CUDA C/C++ programs on Google Colab notebook.

 Requirements:
  • You will need to have a Google account to access Google colab.
  • Internet
Step 1: Go to Google colab and click on New Notebook.

Google colab project selection page.

Step 2: Click on the Runtime menu and then select the Change runtime type option.

Runtime menu. 

Step 3:  Set the Hardware accelerator option to GPU.

Hardware accelerator selection menu.

Step 4: Run the following commands.

Note: Each command should be executed on a different cell.

Step 5: Now paste/write your code in a new cell and run the cell to execute your code.

Note: You have to add ‘%%cu’ at the first line of your cell where your C/C++ code is written.

C program running on Colab.


In this way, we can easily run CUDA C/C++ programs on Google colab for free. Hope, this article will help in your programming journey.