0

I already followed some tutorial in how to install CUDA in Debian 9.

The best one so far, that let me use nvcc was the one you can found in this link.

Now the thing is, I cannot find the toolkit. I already tried to use find command, etc, but nothing. Has anyone any idea where the toolkit is?

Because, whenever I run nvcc to compile a simple "Hello World" program using CUDA, it gives erros because it cannot find the libraries. And when I try to install the samples, it asks for the toolkit path, and I cannot find it.

ADDED:

I installed everything using:

apt-get install nvidia-cuda-dev nvidia-cuda-toolkit  nvidia-driver 

After this, I ran:

nvcc -V

To check if nvcc was installed, the output was this:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016

The I download the .run file for ubuntu 16.04, and CUDA 8.0:

cuda_8.0.61_375.26_linux-run

I the skip the installation of drivers, and the toolkit installation, and jump right to Samples Installation

Do you accept the previously read EULA?
accept/decline/quit: accept

You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /root ]: /home/sergiobranco/cuda_samples

Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: 

Error: cannot find Toolkit in /usr/local/cuda-8.0
Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: ??????????

The problem is that it asks for the toolkit location and I do not know it. I press enter and then I try to install the samples but this is the error:

Error: unsupported compiler: 6.3.0. Use --override to override this check.
Missing recommended library: libXmu.so

Error: cannot find Toolkit in /usr/local/cuda-8.0

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installation Failed. Using unsupported Compiler.
Samples:  Cannot find Toolkit in /usr/local/cuda-8.0


Logfile is /tmp/cuda_install_3212.log

I already used the --override argument, but it fails to.

After this I tried to at least compile one of the "first programs" given by cuda:

#include <stdio.h>

__global__
void saxpy(int n, float a, float *x, float *y)
{
  int i = blockIdx.x*blockDim.x + threadIdx.x;
  if (i < n) y[i] = a*x[i] + y[i];
}

int main(void)
{
  int N = 1<<20;
  float *x, *y, *d_x, *d_y;
  x = (float*)malloc(N*sizeof(float));
  y = (float*)malloc(N*sizeof(float));

  cudaMalloc(&d_x, N*sizeof(float)); 
  cudaMalloc(&d_y, N*sizeof(float));

  for (int i = 0; i < N; i++) {
    x[i] = 1.0f;
    y[i] = 2.0f;
  }

  cudaMemcpy(d_x, x, N*sizeof(float), cudaMemcpyHostToDevice);
  cudaMemcpy(d_y, y, N*sizeof(float), cudaMemcpyHostToDevice);

  // Perform SAXPY on 1M elements
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);

  cudaMemcpy(y, d_y, N*sizeof(float), cudaMemcpyDeviceToHost);

  float maxError = 0.0f;
  for (int i = 0; i < N; i++)
    maxError = max(maxError, abs(y[i]-4.0f));
  printf("Max error: %f\n", maxError);

  cudaFree(d_x);
  cudaFree(d_y);
  free(x);
  free(y);
}

But this is the output:

nvcc -ccbin clang-3.8 hello.c 
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
hello.c:3:1: error: unknown type name '__global__'
__global__
^
hello.c:4:1: error: expected identifier or '('
void saxpy(int n, float a, float *x, float *y)
^
hello.c:14:15: warning: implicitly declaring library function 'malloc' with type 'void *(unsigned long)' [-Wimplicit-function-declaration]
  x = (float*)malloc(N*sizeof(float));
              ^
hello.c:14:15: note: include the header <stdlib.h> or explicitly provide a declaration for 'malloc'
hello.c:17:3: warning: implicit declaration of function 'cudaMalloc' is invalid in C99 [-Wimplicit-function-declaration]
  cudaMalloc(&d_x, N*sizeof(float)); 
  ^
hello.c:25:3: warning: implicit declaration of function 'cudaMemcpy' is invalid in C99 [-Wimplicit-function-declaration]
  cudaMemcpy(d_x, x, N*sizeof(float), cudaMemcpyHostToDevice);
  ^
hello.c:25:39: error: use of undeclared identifier 'cudaMemcpyHostToDevice'
  cudaMemcpy(d_x, x, N*sizeof(float), cudaMemcpyHostToDevice);
                                      ^
hello.c:26:39: error: use of undeclared identifier 'cudaMemcpyHostToDevice'
  cudaMemcpy(d_y, y, N*sizeof(float), cudaMemcpyHostToDevice);
                                      ^
hello.c:29:3: error: use of undeclared identifier 'saxpy'
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
  ^
hello.c:29:10: error: expected expression
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
         ^
hello.c:29:29: error: expected expression
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
                            ^
hello.c:29:31: warning: expression result unused [-Wunused-value]
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
                              ^
hello.c:29:34: warning: expression result unused [-Wunused-value]
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
                                 ^~~~
hello.c:29:40: warning: expression result unused [-Wunused-value]
  saxpy<<<(N+255)/256, 256>>>(N, 2.0f, d_x, d_y);
                                       ^~~
hello.c:31:39: error: use of undeclared identifier 'cudaMemcpyDeviceToHost'
  cudaMemcpy(y, d_y, N*sizeof(float), cudaMemcpyDeviceToHost);
                                      ^
hello.c:35:16: warning: implicit declaration of function 'max' is invalid in C99 [-Wimplicit-function-declaration]
    maxError = max(maxError, abs(y[i]-4.0f));
               ^
hello.c:35:30: warning: implicitly declaring library function 'abs' with type 'int (int)' [-Wimplicit-function-declaration]
    maxError = max(maxError, abs(y[i]-4.0f));
                             ^
hello.c:35:30: note: include the header <stdlib.h> or explicitly provide a declaration for 'abs'
hello.c:35:30: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
    maxError = max(maxError, abs(y[i]-4.0f));
                             ^
hello.c:35:30: note: use function 'fabsf' instead
    maxError = max(maxError, abs(y[i]-4.0f));
                             ^~~
                             fabsf
hello.c:35:30: note: include the header <math.h> or explicitly provide a declaration for 'fabsf'
hello.c:38:3: warning: implicit declaration of function 'cudaFree' is invalid in C99 [-Wimplicit-function-declaration]
  cudaFree(d_x);
  ^
hello.c:40:3: warning: implicit declaration of function 'free' is invalid in C99 [-Wimplicit-function-declaration]
  free(x);
  ^
11 warnings and 8 errors generated.
  • The site you have posted states ...The Debian CUDA packages unfortunately do not include the Toolkit samples. To install these yourself you need to download the "Ubuntu 16.04" .run install file for Cuda 8 from... – Thomas Mar 11 '18 at 11:56
  • Yes, the problem is to install the samples you have to provide the toolkit path... – Indesejavel Coisa Mar 11 '18 at 11:58
  • It might be good if you add more details to your question and outline the steps you already done. Installed the tookit from the Nvidia site? – Thomas Mar 11 '18 at 12:03
  • Added a lot more information... Hope it is enough to explain what I have done – Indesejavel Coisa Mar 11 '18 at 12:53
  • When you run the cuda_8.0.61_375.26_linux-run file and it promptsEnter Toolkit Location [ default is /usr/local/cuda-8.0 ]:, it is asking where you want to install the toolkit, not where it is installed. – Jaken551 Mar 11 '18 at 12:57
2

Well, finally I was able to install everything and is working correctly. I will post here a full tutorial on how I did it for debian 9:

1st Step:

apt-get install nvidia-cuda-dev nvidia-cuda-toolkit  nvidia-driver 

Was to run the command above, you should check this link in order to get a better overview in how to do it correctly for you board.

This been said, then I download the following run file CUDA 8.0

I also had to install these:

apt-get install libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev

Then I had to include the toolkit to my $PATH in order to make it work:

export PATH=$PATH:/usr/lib/nvidia-cuda-toolkit

Then you must do this:

sh /home/username/Downloads/cuda_8.0.61_375.26_linux.run --tar mxvf
cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base/
export $PERL5LIB

And now you can install the samples:

sh /home/username/Downloads/cuda_8.0.61_375.26_linux.run

When it asks for the toolkit path you should put:

/usr/lib/nvidia-cuda-toolkit

This were my answers:

Do you accept the previously read EULA?
accept/decline/quit: accept

You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /root ]: /somewher

Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: /usr/lib/nvidia-cuda-toolkit

It now should install the samples without any trouble. Then you can go to the folder inside where you install them and run:

nvcc -ccbin clang++-3.8 somefile.cu -o somename

And there you go . . .

If you want to install pycuda you have only to do this:

apt-get install build-essential python-dev python-setuptools libboost-python-dev libboost-thread-dev -y
apt-get install python-pycuda

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.