2

I have CUDA and rpud successfully installed. I was able to compile and run my file vecAdd.cu, but I would like to call this function in R. I used the following instruction to create vecAdd.o and vecAdd.so respectively, I got no errors.

nvcc -m64 -I/usr/local/cuda-5.5/include -I/usr/include/R - I/usr/local/include -g -O2 -c -o VecAdd.o VecAdd.cu --ptxas-options -v -Xcompiler -fPIC

g++ -m64 -std=gnu99 -shared -L/usr/local/lib64 -o VecAdd.so VecAdd.o -L/usr/lib64/R/lib -lR -L/usr/local/cuda-5.5/lib64 -lcuda -lcudart -lcurand -lm

When I tried to load it in R using:

> dyn.load("/home/CUDACodes/VecAdd.so")

Error in dyn.load("/home/CUDACodes/VecAdd.so") : unable to load shared object '/home/CUDACodes/VecAdd.so': libcudart.so.5.5: cannot open shared object file: No such file or directory

Don't know if it could be related, but when I tried to install gputools package I got this error:

Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/home/ac43/lib/R/gputools/libs/gputools.so': libcublas.so.5.5: cannot open shared object file: No such file or directory

  • Do you have cuda 5.5 installed? Is your `LD_LIBRARY_PATH` variable [set appropriately](http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#package-manager-installation) before trying to load the `.so` library in R ? – Robert Crovella Sep 13 '13 at 23:52
  • Yes, CUDA 5.5. I think that the LD_LIBRARY_PATH is set appropriately. When it was not I was unable to install rpud. – user2778066 Sep 14 '13 at 00:17
  • 1
    Then R is probably [not picking up your environment](http://stackoverflow.com/questions/3892510/set-environment-variables-for-system-in-r) when you are trying to load the .so library. – Robert Crovella Sep 14 '13 at 00:23
  • This makes sense at all. I probably need to wait the system administrator. Thanks for your help, I am sorry I started using linux three days ago and just modifying the .cshrc file to let CUDA samples work have been a big goal for me. Thanks! – user2778066 Sep 14 '13 at 00:50
  • As you said @RobertCrovella R was not picking my environment. Adding the following line to my .cshrc solved my problem: setenv `R_INC_PATH /usr/lib64/R/include:$LD_LIBRARY_PATH` – user2778066 Sep 14 '13 at 22:25
  • 1
    @user2778066: please add this as an answer so we can get this question off the unanswered question. It is perfectly OK to answer your own questions here on [SO]. – talonmies Sep 15 '13 at 11:33

1 Answers1

2

Adding the following line to the .csrc file fixed it: setenv R_INC_PATH /usr/lib64/R/include:$LD_LIBRARY_PATH