0
votes

I am trying to compile a CUDA 5.5 application on nsight with ubuntu 12.04

At first I was getting an issue about missing header files such as #include <helper_cuda_drvapi.h>

To fix this I added the path /usr/include/samples/common/inc to my includes list.

This solved the missing header file issue but caused a new issue.

when trying to compile the program on nsight I get the following errors

/usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:278: undefined reference to cuInit' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:279: undefined reference tocuDeviceGetCount' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:290: undefined reference to cuDeviceGetName' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:291: undefined reference tocuDeviceComputeCapability' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:294: undefined reference to cuDeviceGetAttribute' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:327: undefined reference tocuDeviceGetAttribute' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:330: undefined reference to cuDeviceGetAttribute' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:333: undefined reference tocuDeviceComputeCapability' /usr/local/cuda-5.5/samples/common/inc/helper_cuda_drvapi.h:336: undefined reference to `cuDeviceGetAttribute'

any suggestions?

Thanks in advance

*****************UPDATE************

What it basically comes down to is I am trying to compile the "CUDA Video Decoder GL API" sample program on linux and it is not working because of some error with the header files. Does anyone know why this is?

UPDATE

enter image description here

enter image description here

enter image description here

enter image description here

2
Try including cuda.h and cuda_runtime.h before helper_cuda_drvapi.h.Roger Dahl
I saw that was how they fixed it with nvcc but I didn't think there was a way to set what gets compiled first with nsightuser2719805
@RogerDahl I believe your comment is correct. The OP obviously doesn't understand it, nor the difference between nsight EE and nvcc. Could you expand your comment into an answer? I would upvote it.Robert Crovella
@RobertCrovella, in this answer, @talonmies mentions that nvcc automatically includes the required headers. I guess helper_cuda_drvapi.h, being part of the sample framework, is intended for use only from .cu files and so doesn't include cuda.h itself?Roger Dahl

2 Answers

1
votes

The undefined references are to CUDA driver API methods. helper_cuda_drvapi.h has the following comment near the top:

Helper functions for CUDA Driver API error handling (make sure that CUDA_H is included in your projects)

So, in your .cu and .cpp files, before the #include <helper_cuda_drvapi.h>, include cuda.h:

#include "cuda.h"
#include <helper_cuda_drvapi.h>

See this question for more information about the CUDA headers.

1
votes

You need to manually link with libcuda (Nsight projects use Runtime API)

To link with this library:

  1. Go to Properties for your project, open General / Path and Symbols
  2. On the Libraries tab add cuda (without prefix or suffix - in theory should make your project more clossplatform. You may also want to check "Add to all configurations" when adding the library - otherwise it will be for your current build configuration (e.g. "Debug" or "Release" only).

Update: Project settings screenshot: enter image description here