Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Last active January 15, 2024 09:34
Show Gist options
  • 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
@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