Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. undefined reference to `cudnnCreate'
QtWS25 Last Chance

undefined reference to `cudnnCreate'

Scheduled Pinned Locked Moved Solved C++ Gurus
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sher_A_Malik
    wrote on last edited by
    #1

    Hi,

    I am new to CUDNN and I just wrote few lines but the problem is even they are not getting compiled. I double checked everything with cudNN. I am on ubuntu 20.04 LTS, using latest QT, cuda 11.2 and cudnn 8.*.

    Problem is I am getting underfined references. For example cudnnCreate

    cudnnHandle_t cudnn;
      CUDNN_CALL(cudnnCreate(&cudnn));
    
    #define CUDA_CALL(f) { \
      cudaError_t err = (f); \
      if (err != cudaSuccess) { \
        std::cout \
            << "    Error occurred: " << err << std::endl; \
        std::exit(1); \
      } \
    }
    

    Below is my pro file.

    QT -= gui
    
    CONFIG += c++14 console
    CONFIG -= app_bundle
    CONFIG -= qml_debug
    #CONFIG += release
    OBJECTS_DIR=obj
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES +=
    
    INCLUDEPATH += /home/sher/dco-intervals/dco_cpp_dev/src/
    #LIBS += /home/sher/NAG/dcl6i33ngl/lib/libdcoc.a
    
    QMAKE_CXXFLAGS += -fPIC
    
    unix|win32: LIBS += -ljsoncpp
    
    CUDNN_PATH = /usr/local/cuda-11.2
    INCLUDEPATH += -I $$(CUDNN_PATH)/include
    LIBS += -L $$(CUDNN_PATH)/lib64 -L/usr/local/lib
    
    QMAKE_CXXFLAGS_RELEASE += -Ofast -march=native
    QMAKE_CXXFLAGS_DEBUG += -g -O0
    
    QMAKE_LFLAGS_DEBUG += -g -O0
    QMAKE_LFLAGS_RELEASE += -Ofast
    
    
    CUDA_DIR      = /usr/local/cuda-11.2
    INCLUDEPATH  += $$CUDA_DIR/include
    QMAKE_LIBDIR += $$CUDA_DIR/lib64
    LIBS += -lcudart -lcuda
    
    
    
    # Path to cuda SDK install
    macx:CUDA_DIR = /Developer/NVIDIA/cuda-11.2
    linux:CUDA_DIR = /usr/local/cuda-11.2
    # Path to cuda toolkit install
    macx:CUDA_SDK = /Developer/NVIDIA/cuda-11.2/samples
    linux:CUDA_SDK = /usr/local/cuda-11.2/samples
    
    #Cuda include paths
    INCLUDEPATH += $$CUDA_DIR/include
    INCLUDEPATH += $$CUDA_DIR/common/inc/
    INCLUDEPATH += $$CUDA_DIR/../shared/inc/
    
    
    
    
    #cuda libs
    macx:QMAKE_LIBDIR += $$CUDA_DIR/lib
    linux:QMAKE_LIBDIR += $$CUDA_DIR/lib64
    QMAKE_LIBDIR += $$CUDA_SDK/common/lib
    #note for dynamic parallelism you need libcudadevrt
    LIBS += -lcudart -lcudadevrt
    QMAKE_CXXFLAGS+= -fopenmp # and pass this option to the linker when linking the project
        QMAKE_LFLAGS += -fopenmp -Ofast -march=native
    # join the includes in a line
    CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
    
    # Define output directories
    DESTDIR = "/home/sher/CU_KERNEL"
    OBJECTS_DIR = "/home/sher/CU_KERNEL/OBJ"
    CUDA_OBJECTS_DIR = "/home/sher/CU_KERNEL"
    CUDA_SOURCES += \
    convolution.cu \
    
    #-DCUDNN_INCLUDE_DIR=path/to/cudnn/include -DCUDNN_LIBRARY=path/to/cudnn/lib64/libcudnn.so
    # include paths
    INCLUDEPATH += $$CUDA_DIR/include \
                   $$CUDA_SDK/common/inc/ \
                   $$CUDA_SDK/../shared/inc/
    INCLUDEPATH += /dclin34nn/include/
    INCLUDEPATH += /home/sher/boostlib/include/
    INCLUDEPATH += /home/sher/CU_KERNEL/
    
    
    # library directories
    QMAKE_LIBDIR += $$CUDA_DIR/lib/$$SYSTEM_NAME \
                    $$CUDA_SDK/common/lib/$$SYSTEM_NAME \
                    $$CUDA_SDK/../shared/lib/$$SYSTEM_NAME
    
    LIBS += -lcuda -lcudart
    LIBS += $$CUDA_LIBS
    NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
    
    # Configuration of the Cuda compiler
    CONFIG(debug, debug|release) {
        # Debug mode
        cuda_d.input = CUDA_SOURCES
        cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
        cuda_d.commands = $$CUDA_DIR/bin/nvcc -D_DEBUG  $$CUDA_INC $$NVCCFLAGS $$NVCC_LIBS --machine 64 --default-stream per-thread -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda_d.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda_d
    
    }
    else {
        # Release mode
        cuda.input = CUDA_SOURCES
        cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
        cuda.commands = $$CUDA_DIR/bin/nvcc  $$CUDA_INC $$NVCCFLAGS $$NVCC_LIBS --machine 64 --default-stream per-thread -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda
    
    }
    
    DISTFILES += \
    
    
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I don't see where you link against the cudnn library which contains this symbol afaics from asking google.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        I don't see where you link against the cudnn library which contains this symbol afaics from asking google.

        S Offline
        S Offline
        Sher_A_Malik
        wrote on last edited by
        #3

        @Christian-Ehrlicher Solved I didn't link -lcudnn it earlier. Now it's working.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved