close

[Solved] How to solve “RuntimeError: CUDA error: invalid device ordinal”?

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error How to solve “RuntimeError: CUDA error: invalid device ordinal”? in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How to solve “RuntimeError: CUDA error: invalid device ordinal” Error Occurs?

Today I get the following error How to solve “RuntimeError: CUDA error: invalid device ordinal”? in Python.

How to solve “RuntimeError: CUDA error: invalid device ordinal” Error ?

  1. How to solve “RuntimeError: CUDA error: invalid device ordinal” Error ?

    to solve “RuntimeError: CUDA error: invalid device ordinal” Error gpu_id is only effective when more more then 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).

  2. How to solve “RuntimeError: CUDA error: invalid device ordinal”?

    to solve “RuntimeError: CUDA error: invalid device ordinal” Error gpu_id is only effective when more more then 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).

Solution 1

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 more then 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).

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment