[Solved]: Deep Learning of Darknet on GPU and error “CUDA Error: invalid device ordinal darknet: ./src/cuda.c:36: check_error: Assertion `0′ failed.”

When You after compilation darknet with GPU=1 option You  received error during execution darknet command like below:

CUDA Error: invalid device ordinal
darknet: ./src/cuda.c:36: check_error: Assertion `0′ failed.
Abandon (core dumped)

that means that You compiled sources with invalid arch attribute.

For instance existing configuration:

for RTX 2080 TI Dual is incorrect and destination valid arch parameter is:

In makefile You should place arch parameter according valid architecture related to Your GPU specification. Below is listed valid parameters:

Sample flags for generation on CUDA 7 for maximum compatibility:

–arch= –gencode=arch=compute_20,code=sm_20 \
–gencode=arch=compute_30,code=sm_30 \
–gencode=arch=compute_50,code=sm_50 \
–gencode=arch=compute_52,code=sm_52 \
–gencode=arch=compute_52,code=compute_52

Sample flags for generation on CUDA 8 for maximum compatibility:

–arch= –gencode=arch=compute_20,code=sm_20 \
–gencode=arch=compute_30,code=sm_30 \
–gencode=arch=compute_50,code=sm_50 \
–gencode=arch=compute_52,code=sm_52 \
–gencode=arch=compute_60,code=sm_60 \
–gencode=arch=compute_61,code=sm_61 \
–gencode=arch=compute_61,code=compute_61

Sample flags for generation on CUDA 9 for maximum compatibility with Volta cards:

–arch= –gencode=arch=compute_50,code=sm_50 \
–gencode=arch=compute_52,code=sm_52 \
–gencode=arch=compute_60,code=sm_60 \
–gencode=arch=compute_61,code=sm_61 \
–gencode=arch=compute_70,code=sm_70 \
–gencode=arch=compute_70,code=compute_70

Sample flags for generation on CUDA 10 for maximum compatibility with Turing cards:

–arch= –gencode=arch=compute_50,code=sm_50 \
–gencode=arch=compute_52,code=sm_52 \
–gencode=arch=compute_60,code=sm_60 \
–gencode=arch=compute_61,code=sm_61 \
–gencode=arch=compute_70,code=sm_70 \
–gencode=arch=compute_75,code=sm_75 \
–gencode=arch=compute_75,code=compute_75