Running C and ++ Cuda in Google Colab

I want to practice CUDA programming (C and C++) in Colab. I watched many videos, read forums but “nvcc” is not working for me.

Steps I followed.

Step 1. Open new Jupyter Notebook in Google Colab and then select GPU Run time

Step 2. I tried adding nvcc4jupyter plugin by below command. It didn’t work

!pip install git+https://github.com/andreinechaev/nvcc4jupyter.git
%load_ext nvcc_plugin

After reading many forums, I tried one more attempt.

Step 1. Followed as above

Step 2. Removed existing CUDA

!apt-get --purge remove cuda nvidia* libnvidia-*
!dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 dpkg --purge
!apt-get remove cuda-*
!apt autoremove
!apt-get update

Step 3. Tried installing CUDA Version 9.2

!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
!apt-get update
!apt-get install cuda-9.2

Step 3. Wanted to check the “nvcc” version by

!nvcc --version

Didn’t work.

Full colab notebook is here → Colab Notebook

Can someone guide on how to use CUDA (C and C++) in Google Colab?

this is a working example

Thanks Robert!!! it helps!