Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Last active January 15, 2024 09:34
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save harshityadav95/e56c525dcc14eec0d4f64eac67ad5102 to your computer and use it in GitHub Desktop.
Save harshityadav95/e56c525dcc14eec0d4f64eac67ad5102 to your computer and use it in GitHub Desktop.
Archived : Initialise CUDA environment on Google Colab
!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
!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
!pip install git+git://github.com/andreinechaev/nvcc4jupyter.git
%load_ext nvcc_plugin
@sanyameepatel
Copy link

Hi Harshit,
Is it possible to update this for CUDA 10? This is really awesome btw.

@harshityadav95
Copy link
Author

Hi Harshit,
Is it possible to update this for CUDA 10? This is really awesome btw.

Not anytime soon , but will update if i try

@merced317
Copy link

The default for Google Colab has been updated to:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

The only two lines required now are the last two:

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

@rakati
Copy link

rakati commented Jun 16, 2020

Hi Harshit,
Is there any extension to profile the Cuda code?

@harshityadav95
Copy link
Author

No i havent used one yet as per my usage

@ekagra-ranjan
Copy link

@merced317 Thanks a lot for pointing it out here!

@reachanihere
Copy link

--2020-08-21 19:20:07-- (try:12) https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64
Reusing existing connection to developer.nvidia.com:443.
HTTP request sent, awaiting response... 504 Gateway Timeout
Retrying.

Any update on the NVIDIA link, I am getting this error now.

@ihariharasudhan
Copy link

The default for Google Colab has been updated to:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

The only two lines required now are the last two:

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

This works! Thank you

@zishugshan
Copy link

- !pip install git+git://github.com/andreinechaev/nvcc4jupyter.git 
+ !pip install git+https://github.com/andreinechaev/nvcc4jupyter.git

⏫ use this for install plugin if you are getting error

@fppgithub
Copy link

thanks u @zishugshan !!!

@Sami3rdm
Copy link

I am getting this error when i run the las CUDA code.
In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/host_config.h:50,
from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:78,
from :
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!
119 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!

Aby Idea How to solve this error Please.

@GUNASEKAR-SRI
Copy link

Hi Harshit, I am getting error while running in google colab. error is gcc

In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/host_config.h:50,
from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:78,
from :
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!
119 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!

Pls help to solve this error

@Nidhi89717
Copy link

Hi Harshit, I am getting error while running in google colab. error is gcc

In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/host_config.h:50, from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:78, from : /usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported! 119 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!

Pls help to solve this error

Don't run step 3 and step 4 commands. It worked for me.

@BENABDALLAH-ANWER
Copy link

hello ,

  • try !apt-get install cuda gcc-5 g++-5

@LysaAitmessaoud
Copy link

Hi Harshit,
Is it possible to update this for CUDA 10? This is really awesome btw.

Not anytime soon , but will update if i try

- !pip install git+git://github.com/andreinechaev/nvcc4jupyter.git 
+ !pip install git+https://github.com/andreinechaev/nvcc4jupyter.git

⏫ use this for install plugin if you are getting error

thank you (y)

@uroojz
Copy link

uroojz commented Jan 14, 2024

i am using this code on google colab 12.2 version to run the CUDA C code but when i run the sample code you provided I get the following error

File "", line 3
global void add(int *a, int *b, int *c) {
^
SyntaxError: invalid syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment