Open cdeterman opened 6 years ago
I believe I nearly have this for Linux builds (and theoretically MacOSX). However, I don't believe this will be possible for Windows given the requirement by NVIDIA's nvcc
compiler demanding use of Visual Studio. This is not supported by R and causes all sorts of other problems. As such, until such a time the NVIDIA allows Windows OS to use the MinGW toolset the CUDA backend for gpuR
will likely be limited to Linux systems.
@PengZhao @rhaunschild you two are users who have a noted interest in CUDA. Could you try to install the cuda
branch of this repository to confirm if it compiles nicely for you? From R you should just need the following commands
Sys.setenv(BACKEND="CUDA")
devtools::install_github("cdeterman/gpuR", ref = "cuda")
If it works, I would encourage you to try and clone the repository branch and try to run the unit tests by opening an R session in the git directory and run
devtools::test()
Congrats @cdeterman! I've tried to install it but got this error:
In file included from /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RViennaCL/include/viennacl/meta/result_of.hpp:41:0, from /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RViennaCL/include/viennacl/scalar.hpp:29, from /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RViennaCL/include/viennacl/tools/entry_proxy.hpp:27, from /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RViennaCL/include/viennacl/detail/matrix_def.hpp:26, from /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RViennaCL/include/viennacl/matrix.hpp:26, from ../inst/include/gpuR/dynVCLMat.hpp:26, from ../inst/include/gpuR/getVCLptr.hpp:5, from gpuMatrix_igemm.cpp:4: /home/dselivanov/R/x86_64-pc-linux-gnu-library/3.4/RcppEigen/include/Eigen/Core:58:34: fatal error: math_functions.hpp: No such file or directory compilation terminated.
I have latest RcppEigen_0.3.3.4.0 installed.
Full traceback:
EDIT here is SO post after quick googling
Thanks @dselivanov what version of RcppEigen
do you have installed?
Latest RcppEigen_0.3.3.4.0 After simlinking (as was suggested on SO) with
sudo ln -s /usr/local/cuda/include/crt/math_functions.hpp /usr/local/cuda/include/math_functions.hpp
I got another portion of errors:
Hmm... odd, it continues to work with my CUDA 8.0 on ubuntu 14.04 docker image. I will try with CUDA 9.1 (as I see that is your version) on ubuntu 16.04 and see what happens.
It seems it is indeed related to cuda 9.1 https://github.com/tensorflow/tensorflow/issues/15389
I recently acquired a laptop with an NVidia 1050Ti. It's currently running Windows 10 Pro with Hyper-V, Docker for Windows and Windows Subsystem for Linux. I have CUDA 9.0 without Visual Studio. I haven't tried anything involving nvcc
yet though; TensorFlow 1.5.0 runs fine on it.
I am doing a lot of work with Docker at the moment but have no immediate plans to dual-boot the machine. I think Hyper-V can see the GPU and export it to a guest VM; I'll try this in a day or so,
I will probably end up with both Visual Studio 2015 and 2017; the Microsoft R Client uses 2017 and the NVidia FORTRAN compiler uses 2015.
@dselivanov I can confirm this same problem on my docker image. I have found a way to resolve the initial problem (so you don't need to symlink) but I am looking in to why the half errors are happening which again appear to be an issue between Eigen and CUDA >= 9.
@dselivanov I have created forks of the BH
and RcppEigen
package that I have updated using the most recent changes in the sources (i.e. boostorg and Eigen) to support CUDA >= 9. Please try installing directly from my github with
devtools::install_github('cdeterman/BH')
devtools::install_github('cdeterman/RcppEigen')
and try to install gpuR
again. I have successfully compiled in my docker image (ubuntu 16.04, cuda 9.1).
I got another error:
@dselivanov Bah..., I forgot as well that you need my github version of RViennaCL
. I am waiting on some pull requests with ViennaCL before I release the updates.
devtools::install_github('cdeterman/RViennaCL')
Then try once more.
Successfully installed (and packages loads normally)!
library(gpuR)
# - context device index: 0
# - GeForce GTX 680
#checked all devices
#completed initialization
#gpuR 2.0.2
#Attaching package: ‘gpuR’
#The following objects are masked from ‘package:base’:
# colnames, pmax, pmin, svd
However devtools::test()
prints:
Error in dyn.load(dllfile) : unable to load shared object '/home/dselivanov/projects/gpuR/src/gpuR.so': /home/dselivanov/projects/gpuR/src/gpuR.so: undefined symbol: cudaMemcpyAsync
Is there an easier way to switch between OpenCL and CUDA backends?
Right now it seems that you have to uninstall/reinstall/rebuild packages between
Sys.setenv(BACKEND="CUDA")
devtools::install_github("cdeterman/gpuR", ref = "cuda")
and regular install.packages
install.packages("gpuR")
It would be nice if there could be one build for both platforms linked to both OpenCL and CUDA libraries and switch context using some flags.
@mjmg I would ideally prefer to have the ability to switch between both backends but I don't think it is possible with ViennaCL. @karlrupp is it possible to use both OpenCL and CUDA concurrently with ViennaCL? If so, perhaps something could be done here.
yes, it is absolutely possible to switch between CUDA and OpenCL backends in ViennaCL at runtime. That's one of the strengths of ViennaCL over other libraries.
@karlrupp are there any examples of this? For example, how could I create two matrices one in OpenCL and one in CUDA?
@cdeterman I tried installing cuda-backed gpuR but can't get any of the cuda functions to work. For example, if I try creating a vclMatrix, I receive the error
Error in vectorToMatVCL(data, nrow, ncol, 8L, context_index - 1) :
/home/jonpeake/R/x86_64-pc-linux-gnu-library/3.5/RViennaCL/include/viennacl/linalg/cuda/matrix_operations.hpp(334): : getLastCudaError() CUDA error 48: no kernel image is available for execution on the device @ matrix_row_assign_kernel
Same thing happens if I try to multiply two gpuMatrix objects:
Error in cpp_gpuMatrix_elem_prod(A@address, is(A, "vclMatrix"), B@address, :
/home/jonpeake/R/x86_64-pc-linux-gnu-library/3.5/RViennaCL/include/viennacl/linalg/cuda/matrix_operations.hpp(334): : getLastCudaError() CUDA error 48: no kernel image is available for execution on the device @ matrix_row_assign_kernel
My GPU info is below, running CUDA 10.0 on Ubuntu 18.04:
> gpuInfo()
$deviceName
[1] "GeForce GTX 960"
$deviceVendor
[1] "NVIDIA"
$majorVersion
[1] 5
$minorVersion
[1] 2
$numberOfMultiProcs
[1] 8
$sharedMemPerBlock
[1] 49152
$regsPerBlock
[1] 65536
$warpSize
[1] 32
$deviceMemory
[1] 4236902400
$deviceConstMemory
[1] 65536
$clockFreq
[1] 1253000
$double_support
[1] TRUE
Any idea what's going on?
@cdeterman Never mind! Figured out that RStudio doesn't automatically import system environment variables if opened from the desktop, I needed to open from command line for it to import.
It has occurred to me, during my toying with gpuRcuda that I should be able to find a way to simply allow the user to indicate they wish to use the CUDA backend. After all, ViennaCL is intended to make an interface for both OpenCL and CUDA. This was not pursued previously because Rcpp and the
nvcc
compiler were not playing nice together. This has changed very recently with some changes to Rcpp.If I am able to success in this, then gpuRcuda will no longer be relevant. Instead, I would work to interface with relevant CUDA extensions like cublas with gpuRcublas directly from gpuR.