[R-sig-hpc] A few questions on using R and CUDA

Qiang Kou qkou @end|ng |rom |u@edu
Thu Mar 7 19:52:51 CET 2019


The page 8 in the slides is showing what you are asking for.

After putting libnvblas.so in LD_PRELOAD, when R calls any blas function, nvblas would be used.

Best,

KK

On 3/7/19, 10:41 AM, "R-sig-hpc on behalf of Nafis Sadat" <r-sig-hpc-bounces using r-project.org on behalf of sadatnfs using uw.edu> wrote:

    Awesome, thanks Andrew and Qiang! One follow up question I have is: is it simply possible to just ‘replace’ the native BLAS that I built in R with the NVBLAS library? Hence, instead of calling a function explicitly from the CUDA headers, I would want to just have any BLAS functions be called from NVBLAS… is that even possible?
    
    From: Andrew Ekstrom <aekstrom using umich.edu>
    Date: Thursday, March 7, 2019 at 10:35 AM
    To: Qiang Kou <qkou using iu.edu>
    Cc: Nafis Sadat <sadatnfs using uw.edu>, "r-sig-hpc using r-project.org" <r-sig-hpc using r-project.org>
    Subject: Re: [R-sig-hpc] A few questions on using R and CUDA
    
    When you use Cuda, make sure your GPU can handle the current version of Cuda C and that you have enough ram on your GPU to handle the amount of data you are processing. Also be aware that most Cuda programs use float, not double float. That can lead you to vastly different answers if you are using an iterative process.
    
    On Thu, Mar 7, 2019 at 1:21 PM Qiang Kou <qkou using iu.edu<mailto:qkou using iu.edu>> wrote:
    Hi, Nafis,
    
    To use NVBLAS with R, please see the page 8 in the slides below:
    
    http://www.parallelr.com/slides/ParallelR-Accelerating%20R%20Applications%20with%20CUDA.pdf
    
    Best wishes,
    
    KK
    
    On Thu, Mar 7, 2019 at 9:15 AM Nafis Sadat <sadatnfs using uw.edu<mailto:sadatnfs using uw.edu>> wrote:
    
    > Hi everyone:
    >
    > My name is Nafis Sadat, and I am a software engineer at the University of
    > Washington. I've been doing some research on the side recently on looking
    > at R and GPU capabilities, and after pinging Dr. Dirk Eddelbuettel (after
    > finding out his work on the 'gcbd' package), he suggested that I can send
    > out my question to the r-sig-hpc mailing list hoping for some answers!
    >
    > I work in the geospatial sciences team in my institute, where we try to
    > model diseases at the pixel level around the world using spatial modeling
    > methods. The models that our researchers use are written using the R
    > packages INLA (http://www.r-inla.org/) and TMB (
    > https://github.com/kaskr/adcomp/wiki); all of the code base is entirely
    > in R. One issue that we simply can't avoid is the large dimension of the
    > data (so, if we were modeling at a finer mesh for example, we would have
    > more parameters to optimize, and that leads to longer model runtimes).
    >
    > A year ago, there was no work done in the team to try and optimize this
    > part of the process, but then I worked with another software engineer to
    > compile R from source using the BLAS/LAPACK provided by Intel MKL, and that
    > sped up things pretty decently when it came to a lot of matrix algebra. In
    > fact, both the INLA and TMB packages are built by linking against BLAS (and
    > I have confirmed that the MKL is indeed being used when I run the model by
    > doing a verbose trace). Fast forward to now, and I came across this page:
    > https://developer.nvidia.com/cublas.
    >
    > I have a machine lying around at home which has an Nvidia GPU and the line
    > where Nvidia claims that "cuBLAS performs up to 35X faster than the latest
    > version of the MKL BLAS on common benchmarks". I have not looked into super
    > details about the backend of this (and only recently I have been coming
    > across the .cu extensions...). In an ideal world, if I could simply build R
    > by linking to the CUDA BLAS instead of the MKL BLAS and have everything
    > else run as-is, then that would be the dream, but after fudging around
    > earlier today where I tried to symlink 'libnvblas.so' to 'libblas.so', that
    > build of R was quite a failure.
    >
    > If anyone here would happen to have any thoughts or suggestions on this, I
    > would absolutely love your inputs. I have not found any answers on this on
    > Google, and I just posted a question on Stack Overflow, so I'm hoping that
    > I can learn more about this!
    >
    > Thanks everyone for your patience in reading through this!
    >
    > Nafis
    >
    >
    >
    >
    > Nafis Sadat
    > Software Engineer
    > Institute for Health Metrics and Evaluation | University of Washington
    > 2301 5th Avenue, Suite 600 | Seattle, WA 98121| USA
    > Tel: +1-206-897-3726<tel:+1%20206-897-3726> | Fax:
    > +1-206-897-2899<tel:+1%20206-897-2899> | Campus Mailbox: 358210
    > sadatnfs using uw.edu<mailto:sadatnfs using uw.edu><mailto:sadatnfs using uw.edu<mailto:sadatnfs using uw.edu>> | http://www.healthdata.org<
    > http://www.healthdata.org/>
    >
    >
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-hpc mailing list
    > R-sig-hpc using r-project.org<mailto:R-sig-hpc using r-project.org>
    > https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
    >
    
            [[alternative HTML version deleted]]
    
    _______________________________________________
    R-sig-hpc mailing list
    R-sig-hpc using r-project.org<mailto:R-sig-hpc using r-project.org>
    https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
    
    	[[alternative HTML version deleted]]
    
    _______________________________________________
    R-sig-hpc mailing list
    R-sig-hpc using r-project.org
    https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
    


More information about the R-sig-hpc mailing list