[R-sig-hpc] Use GPU in R with .Call
simon.urbanek at r-project.org
Mon Jul 23 03:00:06 CEST 2012
On Jul 22, 2012, at 5:41 PM, Norm Matloff wrote:
> I'm not exactly sure what you are asking, Raymond, but this may answer
> your question.
> Say you have a file x.cu. After compiling with nvcc -c as you did, then
> do something like this:
> setenv PKG_LIBS "-L/usr/local/cuda/lib -lcudart"
> R CMD SHLIB x.o -o x.so
> PKG_LIBS is an environment variable used by R CMD SHLIB.
FWIW the above will only work in csh (this is after many years that I see someone positing advice based on csh - I thought it died out ;)) and Rtools don't have csh (unsurprisingly).
It's much easier and more portable to simply pass the flags directly to SHLIB - it's not a package after all. In Raymond's case something like
R CMD SHLIB VecAdd_cuda.c VecAdd_kernel.o -lcudart
Add -L if needed, but on Windows it's typically easiest to have DLLs in the same directory. I don't use CUDA so if in doubt, ask nvidia specialists for the exact flags.
> Of course, you need to translate the setting of the environment variable
> from Linux C shell to Windows, and substitute your location of the CUDA
> R-sig-hpc mailing list
> R-sig-hpc at r-project.org
More information about the R-sig-hpc