cutil problem compilation issue

Hi,

I’m very new but trying. I am running this all from SSH

I’ve tried to compile the program squareArray.cu using this command:

$ /usr/local/cuda/bin/nvcc squareArray.cu -lcutil -I /usr/local/cuda/NVIDIA_CUDA_SDK/lib -L /usr/local/cuda/NVIDIA_CUDA_SDK/lib

squareArray.cu:3:20: error: cutil.h: No such file or directory

squareArray.cu:63:5: warning: no newline at end of file

and it gives me this error when running $: ./a.out

NVIDIA: could not open the device file /dev/nvidiactl (No such file or directory).

sh: pause: not found

sh: pause: not found

I’ve tried searching for this error and it said to use X server, which I did, and still the same error.

Here is my exact code.

[codebox]#include <stdio.h>

#include <cuda.h>

#include <cutil.h>

// Kernel that executes on the CUDA device

global void square_array(float *a, int N)

{

int idx = blockIdx.x * blockDim.x + threadIdx.x;

if (idx<N) a[idx] = a[idx] * a[idx] ;

__syncthreads();

}

// main routine that executes on the host

int main(void)

{

float *a_h, *a_d; // Pointer to host & device arrays

float *a,*b;

unsigned int timer = 0;

cutCreateTimer( &timer );

unsigned int timercpu = 0;

cutCreateTimer( &timercpu );

const int N = 400; // Number of elements in arrays

size_t size = N * sizeof(float);

a_h = (float *)malloc(size); // Allocate array on host

a = (float *)malloc(size);

b = (float *)malloc(size);

cudaMalloc((void **) &a_d, size); // Allocate array on device

// Initialize host array and copy it to CUDA device

for (int i=0; i<N; i++)

   a_h[i] = (float)i;  

cudaMemcpy(a_d, a_h, size, cudaMemcpyHostToDevice);

// Do calculation on device:

int block_size = 1;

int n_blocks = N/block_size + (N%block_size == 0 ? 0:1);

cutStartTimer( timer ); // Start timer

square_array <<< n_blocks, block_size >>> (a_d, N);

cutStopTimer( timer ); // Stop timer

// Retrieve result from device and store it in host array

cudaMemcpy(a_h, a_d, sizeof(float)*N, cudaMemcpyDeviceToHost);

// Print results

printf(“CUDA execution time = %f ms\n”,cutGetTimerValue( timer ));

// Cleanup

free(a_h); cudaFree(a_d);

system(“pause”);

cutStartTimer( timercpu ); // Start timer

for (int i=0; i<N; i++) { a[i] = (float)i;

b[i]= a[i] * a[i] ;

}

cutStopTimer( timercpu ); // Stop timer

printf("CPU execution time = %f ms\n",cutGetTimerValue( timercpu )); 

system(“pause”);

return 0;

} [/codebox]

Cutil is a little library that nVidia uses only for the purposes of building their SDK projects. I’m sure it speeds things up a bit for them, but frankly it is confusing for a large number of first-time CUDA programmers, so I really wish they’d just get rid of it already.

In any case…what kind of system are you SSH’ing into? If it’s not the supported version of Ubuntu, perhaps the directory structure is a little different, and then you’d need to edit the nvcc configuration files to get the include paths right.

I don’t know about the “/dev/nvidiactl” error though, sorry. I’m not much help with linux-specific stuff.

The -I flag is for header file includes correct? You should be pointing to the SDK inc directory, not lib…

edit:

Something like:

[codebox]$ /usr/local/cuda/bin/nvcc squareArray.cu -lcutil -I /usr/local/cuda/NVIDIA_CUDA_SDK/inc -L /usr/local/cuda/NVIDIA_CUDA_SDK/lib[/codebox]

I’m surprised you even got an a.out if nvcc failed…

There is no pause command in POSIX systems, that is windows specific, which is why the program is complaining about that. If you are seeing /dev/nvidiactl errors, it either means X11 isn’t running (in which case you should either start it or follow the instructions in the install notes to create the Nvidia specific devices), or the system you are using isn’t running the Nvidia drivers at all.

You can also disregard the suggestion to edit nvcc configuration files, because the linux version doesn’t have any user editable configuration, just command line switches.

Try removing the spaces after the -I and -L switches.

N.

This didn’t do anything, I still get the error that

These two things in combination didn’t do anything, I still get the error that cutil.h is not a file or directory.

Ohh and you were right Jph2599, there was no a.out after putting in the cutil.h header. the a.out was from a compilation without cutil.h header.

anyone new suggestions?

The cutil.h file is located in PATH_TO_NVIDIA_CUDA_SDK_PARENT/NVIDIA_CUDA_SDK/common/inc
not PATH_TO_NVIDIA_CUDA_SDK_PARENT/NVIDIA_CUDA_SDK/inc

N.

david@quadro:~/build/square$ nvcc -I/home/david/NVIDIA_CUDA_SDK/common/inc -I/opt/cuda/include -L/opt/cuda/lib -L/home/david/NVIDIA_CUDA_SDK/lib square.cu -lcutil -lcuda -lcudart

david@quadro:~/build/square$ ./square 

CUDA execution time = 0.028000 ms

sh: pause: not found

CPU execution time = 0.007000 ms

sh: pause: not found

My guess is that something isn’t installed where you think it is…

…/common/inc instead of just …/inc

This worked, thank you.