cudnn linking error using CMAKE

I am a beginner at Cuda and Cudnn programming, and in the following simple code (on my TX2 platform)

#include <iostream>
    #include <cuda_runtime_api.h>
    #include <cudnn.h>
    int main(int argc, char** argv) {
    	cudaStream_t stream;
    	cudnnHandle_t dnn;
    	cudnnSetStream(dnn, stream);
	    // some DNN code //
	    return 0;
    }

i am facing this linking error

undefined reference to `cudnnSetStream’

This is my CMakeLists.txt :

cmake_minimum_required(VERSION 2.6)
    project(testing)

    find_package(CUDA 8.0 REQUIRED)
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -O3;
					-gencode arch=compute_62,code=sm_62;
					-x cu)
    include_directories(${CUDA_INCLUDE_DIRS})

    cuda_add_executable(testing code.cu)
    target_link_libraries(testing ${CUDA_LIBRARIES})

Cudnn libraries are installed properly, as they are being used in Caffe framework without any problem
However in my project I am yet unable to find a resolution to this issue

Hi,

cuDNN libraries is located at ‘/usr/lib/aarch64-linux-gnu/’ rather than CUDA folder.
Please check our official sample for more information: usr/src/cudnn_samples_v7/mnistCUDNN/Makefile

Thanks.

thanks @AastaLLL
the correct linking for this is as follows

cmake_minimum_required(VERSION 2.6)
    project(testing)

    find_package(CUDA 8.0 REQUIRED)
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -O3;
					-gencode arch=compute_62,code=sm_62;
					-x cu)
    include_directories(${CUDA_INCLUDE_DIRS})
    include_directories(/usr/lib/aarch64-linux-gnu)

    cuda_add_executable(testing code.cu)
    target_link_libraries(testing ${CUDA_LIBRARIES} cudnn)
2 Likes