andreinechaev/nvcc4jupyter

cuda_runtime.h error on kaggle

Closed this issue · 4 comments

I am trying to run a basic CUDA code on kaggle.

%%cuda
#include <stdio.h>
​
__global__ void HelloKernel() {
    printf("\tHello from GPU (device)\n");
}
​
int main() {
  printf("Hello from CPU (host) before kernel execution\n");
  HelloKernel<<<1,32>>>();
  cudaDeviceSynchronize();
  printf("Hello from CPU (host) after kernel execution\n");
  return 0;
}

The same code works fine on Colab but on Kaggle it gives this error.

cc1plus: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.

Any idea on what might be causing this?

Hello @mmmovania,

According to this post from the nvidia forum, it looks like a broken CUDA install. I will test it as soon as I have time to see if there is a solution for it.

The problem seems to be that the "nvidia-cuda-toolkit" package is not installed. After this, it seems that another error appears that is related to a wrong version of gcc. You can fix it by adding a new directory to the PATH environment variable (at the beginning so it is prioritized) where you put a symbolic link to the correct gcc version that is already installed in kaggle.

Cell 1:

!apt install -y nvidia-cuda-toolkit; mkdir /usr/bin/priority; ln -s /usr/bin/gcc-8 /usr/bin/priority/gcc

Cell 2:

import os
os.environ["PATH"] = "/usr/bin/priority:" + os.environ["PATH"]

If this does not solve your problem feel free to reopen the issue.

Yep that was it. It works :)

The extension now runs these steps for you when it is loaded.