How to solve "RuntimeError: CUDA error: invalid device ordinal"?
I'm trying to run this code. I don't know what is wrong with it, but this code is not running. and I don't know how to solve this problem.
import cv2
from facial_emotion_recognition import EmotionRecognition

emotion_detector = EmotionRecognition(device='gpu', gpu_id=1)
camera = cv2.VideoCapture(0)

while True:
    image = camera.read()[1]
    image = emotion_detector.recognise_emotion(image, return_type='BGR')
    cv2.imshow('Camera', image)

    key = cv2.waitKey(1)
    if key == 27:
        break

camera.release()
cv2.destroyAllWindows()

but I'm getting this error:
Traceback (most recent call last):
  File &quot;/home/fahim/Documents/Python_projects/Python tutorials/pantech AI Master/Computer_Vision/Day 8 Face emotion recognition/emotion.py&quot;, line 4, in &lt;module&gt;
    emotion_detector = EmotionRecognition(device='gpu', gpu_id=1)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/facial_emotion_recognition/facial_emotion_recognition.py&quot;, line 25, in __init__
    self.network = NetworkV2(in_c=1, nl=32, out_f=7).to(self.device)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 607, in to
    return self._apply(convert)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 354, in _apply
    module._apply(fn)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 354, in _apply
    module._apply(fn)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 376, in _apply
    param_applied = fn(param)
  File &quot;/home/fahim/anaconda3/envs/Computer_Vision/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 605, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA error: invalid device ordinal

Process finished with exit code 1

This is my the configuration of my computer:
GPU: NVIDIA GeForce MX130
CPU: Intel i5-10210U (8) @ 4.200GHz
Help me to solve this please.

Try changing:
emotion_detector = EmotionRecognition(device='gpu', gpu_id=1)

To:
emotion_detector = EmotionRecognition(device='gpu', gpu_id=0)

gpu_id is only effective when more than one GPU is detected, you only seem to have one GPU, so it throws an error since you tell the function to get GPU 2 (since we count from 0).
