Skip to content

Instantly share code, notes, and snippets.

@refactormyself
Created June 7, 2020 14:35
Show Gist options
  • Save refactormyself/cb75b999e0badb30c9e4454b6a1f165e to your computer and use it in GitHub Desktop.
Save refactormyself/cb75b999e0badb30c9e4454b6a1f165e to your computer and use it in GitHub Desktop.
CUDA in Colab

CELL 1

# install the world of CUDA

!apt update -qq;
!wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb;
!dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb;
!apt-key add /var/cuda-repo-8-0-local-ga2/7fa2af80.pub;
!apt-get update -qq;
!apt-get install cuda gcc-5 g++-5 -y -qq;
!ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc;
!ln -s /usr/bin/g++-5 /usr/local/cuda/bin/g++;
!apt install cuda-8.0;

CELL 2

!/usr/local/cuda/bin/nvcc --version

CELL 3

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

CELL 4

# load the extension

%load_ext nvcc_plugin

CELL 5

!gcc --version

CELL 6

# this should work
%%cu
#include <stdio.h>
// this is a cell for CUDA code
int main()
{
    printf("yes, it worked");
    return 1;
}

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