Search code examples
runtime-errorgoogle-colaboratorynvidiasam

How to set "device" in Facebook SAM when I run it Google's Colab without NVIDIA GPU?


import sys
sys.path.append("..")
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor

sam_checkpoint = "sam_vit_h_4b8939.pth"
model_type = "vit_h"

**device = "cuda"**

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

How to avoid this?

import sys
sys.path.append("..")
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor

sam_checkpoint = "sam_vit_h_4b8939.pth"
model_type = "vit_h"

**device = "cuda"**

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

How to avoid this? Runnin in Google's Colab.


Solution

  • You probably did not enable GPU in your runtime.

    On Google Colab, choose Runtime > Change Runtime Type and set Hardware Accelerator to GPU.