Cuda
From Mandriva Community Wiki
Contents |
Using the RPM package
As of 2009.1 and up, nvidia-cuda-* packages can be found in the non-free repository.
A backport seems to exist for Mandriva 2009.0 on some ftp servers, but you should only use it for testing. It is very bad for production and security (read ahead).
The nvidia way
I have used Fedora 9 packages for Mandriva 2008.1 : works ok.
You can download files from Cuda's page on the nVidia website.
chmod 777 *
urpmi before you start
- gcc
- gcc-c++
graphic driver : NVIDIA-Linux-x86-180.22-pkg1.run
this is the usual Nvidia graphic driver, so :
- you need to be in text mode (init level 3)
- as root
- No need for this driver on text only emulation CUDA servers
Toolkit : ./cudatoolkit_X.X_linux32_fedora9.run
- as root
- destination : /usr/local/cuda
- no problems
SDK : ./cuda-sdk-linux-X.YY.ZZZZ.ZZZZ-ZZZZ.run
- no need to be root
- destination : ~/NVIDIA_CUDA_SDK/
- this package seems optional, I did not need it to compile. this could be only tutorials.
- Please make sure your PATH includes /usr/local/cuda/bin
- Please make sure your LD_LIBRARY_PATH includes /usr/local/cuda/lib
PATH=$PATH:/usr/local/cuda/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
or the definitive method :
#/etc/profile add : PATH=$PATH:/usr/local/cuda/bin
#/etc/ld.so.conf add : /usr/local/cuda/lib
To uninstall the NVIDIA CUDA SDK, please delete ~/NVIDIA_CUDA_SDK
Then you have to run as root :
ldconfig
f you don't run this at root, you'll have the message at run time :
./run: error while loading shared libraries: libcudart.so.2: cannot open shared object file: No such file or directoryI had to logout - login too (?)
Your installation should be complete.
Compilation
I succeeded in compiling this program (remember I set the path) :
nvcc -o run prog.cu
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void mykernel(float * A, float * B, float * C)
{
int p = threadIdx.x;
C[p] = A[p] + B[p];
}
int main()
{
float A[]={1,2,3,4,5,6,7,8,9};
float B[]={10,20,30,40,50,60,70,80,90};
float C[9];
//9 sums, no loop !
mykernel<<<1,9>>>(A,B,C);
//output
for(int i=0; i<9 ; i++)
printf("%f\n",C[i]);
}
CUDA and Qt
Create an object file using -c option :
nvcc -c -o kernel.o kernel.cu
Then include your kernel.o file into your Qt Makefile as usual (line OBJECTS=).
Execution
nvcc -deviceemu -o run prog.cu
libcudart.so.2: No such file or directory
-> see installation note *
./run 11.000000 22.000000 33.000000 44.000000 55.000000 66.000000 77.000000 88.000000 99.000000
It works fine in emulation mode using Mandriva 2008.1.
Original author : dsant_0 (Lyon, France). E-mail : forum (at) votreservice (point) com

