Search code examples
cudagoogle-drive-apigoogle-colaboratory

How to read files/images with CUDA in Google Colab?


I'm learning CUDA and as I don't currently own a GPU I'm using Colab. The idea of doing some image processing crossed my mind but I haven't found a way to load images to my program.

I know with python is possible to access your google drive but I'm using CUDA C++. Anybody got any suggestions, please?


Solution

  • You can use the following code to mount a folder from your Google Drive.

    Then use it as you usually access files from C.

    from google.colab import drive
    drive.mount('/content/drive')
    
    %cd "/content/drive/My Drive/Your Folder"
    !pwd