17

I am trying to profile cuda code on Ubuntu 16.04 having Cuda 8.0 but it is returning "Unable to profile application. Unified Memory profiling failed". I tried profiling from terminal and also from Nisght Eclipe. Code is compiling and running but not is not able to get profiled.

Code-

cusparseHandle_t handle;
cusparseCreate(&handle);
cusparseSafeCall(cusparseCreate(&handle));

//set the parameters
const int n_i = 10;
const int d = 18;
const int n_t = 40;
const int n_tau = 2;
const int n_k = 10;

float *data = generate_matrix3_1(d, n_i, n_t);
//float* data = get_data1(d, n_i,n_t);
float* a = generate_matrix3_1(n_i,n_k,n_tau);
float* b = sparse_generate_matrix1(n_k,d,0.5);
float* c = sparse_generate_matrix1(n_k,d,0.5);

float* previous_a = generate_matrix3_1(n_i,n_k,n_tau);
float* previous_b = sparse_generate_matrix1(n_k,d,0.1);
float* previous_c = sparse_generate_matrix1(n_k,d,0.1);

// calculate norm of data
float norm_data = 0;
for (int i = 0; i < n_i; i++)
{
    for (int t = n_tau; t < n_t; t++)
    {
        for (int p = 0; p < d; p++)
        {
            norm_data = norm_data + ((data[p*n_i*n_t + i*n_t + t])*(data[p*n_i*n_t + i*n_t + t]));
        }
    }
}

// set lambda and gamma parameter
float lambda = 0.0001;
float gamma_a = 2;
float gamma_b = 3;
float gamma_c = 4;

float updated_t = 1;
float updated_t1 = 0;

float rel_error = 0;
int loop = 1;
float objective = 0;

// create sparse format for the data
float **h_data = new float*[1];
int **h_data_RowIndices = new int*[1];
int **h_data_ColIndices = new int*[1];
int nnz_data = create_sparse_MY(data,d,n_i*n_t,h_data,h_data_RowIndices,h_data_ColIndices);

// transfer sparse data to device memory
int *d_data_RowIndices;  (cudaMalloc(&d_data_RowIndices, (d+1) * sizeof(int)));
(cudaMemcpy(d_data_RowIndices, h_data_RowIndices[0], (d+1) * sizeof(int), cudaMemcpyHostToDevice));
int *d_data_ColIndices;  (cudaMalloc(&d_data_ColIndices, nnz_data * sizeof(int)));
(cudaMemcpy(d_data_ColIndices, h_data_ColIndices[0], (nnz_data) * sizeof(int), cudaMemcpyHostToDevice));

Command for compiling the code-

nvcc -lcusparse main.cu -o hello.out

Profiling-

nvprof -o prof ./hello.out

Error-

==13621== NVPROF is profiling process 13621, command: ./hello.out ======== Error: unified memory profiling failed.

Can someone help me with it?

newbie
  • 443
  • 1
  • 4
  • 14

3 Answers3

26

had the same misleading error, just had to run the profiler with root privileges, e.g. sudo nvprof or sudo nvvp.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
Stefan Hobeditz
  • 276
  • 3
  • 3
12

I suffers the same error. But the error remains even I add sudo privilege. The terminal returns sudo: nvprof: command not found.

Try this command, it works for me. nvprof --unified-memory-profiling off /hello.out

yan zhang
  • 345
  • 4
  • 9
  • 3
    You should add cuda path to PATH for root or give the exact path after sudo like = "sudo /usr/local/cuda-8.0/bin/nvprof" – Muhammet Ali Asan Aug 16 '17 at 21:05
  • 1
    Some user suggests: *if you get this error from terminal: sudo: nvprof: command not found You can try sudo -su. * – GhostCat Sep 02 '17 at 06:32
  • `/usr/local/cuda/bin/nvprof python file.py` is also right for me without `sudo` – skytree Aug 10 '18 at 09:02
  • `sudo /usr/local/cuda/bin/nvprof ./cuda_app > ./log/stdout.txt 2> ./log/gpu_log.txt` will work. – skytree Oct 19 '18 at 20:45
  • Switching off unified memory profiling may not be a good idea for those who are interested in profiling unified memory usage. Is there any other alternative? – MuneshSingh Jun 02 '19 at 16:45
-1

You don't need root access to fix this. Since you are using Cuda 8.0 this should be working. The problem lies in the 'iBUS' config. All you have to do is delete the folder /home/[user]/.config/ibus/bus and the problem will be gone.

Pasindu
  • 81
  • 8