Fatal error: cuda_runtime_api.h: No such file or directory

  • Upgraded the nvidia driver from 460 to 470 to run the DS 6.0
    While compiling deepstream-test1 facing this issue.
root@707d5bf20d43:/opt/nvidia/deepstream/deepstream-6.0/sources/apps/sample_apps/deepstream-test1# make
cc -c -o deepstream_test1_app.o -I../../../includes -I /usr/local/cuda-11.4/include -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include deepstream_test1_app.c
deepstream_test1_app.c:26:10: fatal error: cuda_runtime_api.h: No such file or directory
#include <cuda_runtime_api.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:63: recipe for target 'deepstream_test1_app.o' failed
make: *** [deepstream_test1_app.o] Error 1


What could be the reason?

It is because the path the app is not able to find your path to CUDA libs.
Solve this error by pasting the following in your .bashrc

# CUDA
export CUDA=11.2
export PATH=/usr/local/cuda-$CUDA/bin${PATH:+:${PATH}}
export CUDA_PATH=/usr/local/cuda-$CUDA
export CUDA_HOME=/usr/local/cuda-$CUDA
export LIBRARY_PATH=$CUDA_HOME/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda-$CUDA/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export NVCC=/usr/local/cuda-$CUDA/bin/nvcc
export CFLAGS="-I$CUDA_HOME/include $CFLAGS"

Don’t forget to follow up with source ~/.bashrc or source ~/.zshrc