I have code below for Deepstream 6.4 sgie, I compile the code with command ‘CUDA_VER=12.2 make’. When I run deepstream, it show the error.
terminate called after throwing an instance of 'thrust::system::system_error'
what(): This program was not compiled for SM 89
: cudaErrorInvalidDevice: invalid device ordinal
Aborted (core dumped)
How could I solve the problem?
My Hardware:
Wed Feb 5 22:44:42 2025
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.147.05 Driver Version: 525.147.05 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | Off |
| 0% 42C P8 22W / 450W | 394MiB / 24564MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1749 G /usr/lib/xorg/Xorg 277MiB |
| 0 N/A N/A 2073 G /usr/bin/gnome-shell 83MiB |
+-----------------------------------------------------------------------------+
This forum is for the NVIDIA HPC Compilers, so unfortunately I’m not familiar with Deepstream. I’ll do my best to help, but we may need to move your post to a different forum.
Now the error is likely due to the application not being built with the correct code generation options to nvcc, i.e. “-gencode arch=compute_89,code=sm_89”.
In looking at the CMakelist.txt file, I do see the correct flags being used, so I’m wondering if you used cmake to configure the project before running make? Running make by itself appears to not add the flags as well as use g++ to compile, not nvcc.
I think it is a NVCC problem because the nvdsinfer library cause the error when loading the nvdsinfer library. This error will occur even I did not use cmake to generate make file. There is a make file inside the folder which is form the NVIDIA example .
################################################################################
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
################################################################################
CUDA_VER?=
ifeq ($(CUDA_VER),)
$(error "CUDA_VER is not set")
endif
TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)
CC:= g++
NVCC:=/usr/local/cuda-$(CUDA_VER)/bin/nvcc
CFLAGS:= -g -Wall -std=c++11 -shared -fPIC -Wno-error=deprecated-declarations
CFLAGS+= -I/opt/nvidia/deepstream/deepstream/sources/includes -I/usr/local/cuda-$(CUDA_VER)/include
CUFLAGS:= -I/opt/nvidia/deepstream/deepstream/sources/includes -I/usr/local/cuda-$(CUDA_VER)/include \
-gencode arch=compute_61,code=compute_61 -gencode arch=compute_70,code=compute_70 \
-gencode arch=compute_75,code=compute_75 -gencode arch=compute_80,code=compute_80 \
-gencode arch=compute_86,code=compute_86 -gencode arch=compute_90,code=compute_90
ifeq ($(TARGET_DEVICE),aarch64)
CUFLAGS+= -gencode arch=compute_72,code=compute_72 -gencode arch=compute_87,code=compute_87
else
CUFLAGS+= -gencode arch=compute_60,code=compute_60 -gencode arch=compute_89,code=compute_89
endif
LIBS:= -lnvinfer_plugin -lnvinfer -lnvparsers -L/usr/local/cuda-$(CUDA_VER)/lib64 -lcudart -lcublas -lstdc++fs
LFLAGS:= -shared -Wl,--start-group $(LIBS) -Wl,--end-group
INCS:= $(wildcard *.h)
SRCFILES:= nvdsinfer_yolo_engine.cpp \
nvdsparsebbox_Yolo.cpp \
yoloPlugins.cpp \
trt_utils.cpp \
yolo.cpp \
kernels.cu \
NvDsInferParseCustomYolov3_cuda.cu
TARGET_LIB:= libnvdsinfer_custom_impl_Yolo_sgie2.so
TARGET_OBJS:= $(SRCFILES:.cpp=.o)
TARGET_OBJS:= $(TARGET_OBJS:.cu=.o)
all: $(TARGET_LIB)
%.o: %.cpp $(INCS) Makefile
$(CC) -c -o $@ $(CFLAGS) $<
%.o: %.cu $(INCS) Makefile
$(NVCC) -c -o $@ --compiler-options '-fPIC' $(CUFLAGS) $<
$(TARGET_LIB) : $(TARGET_OBJS)
$(CC) -o $@ $(TARGET_OBJS) $(LFLAGS)
clean:
rm -rf $(TARGET_LIB) *.o