s-u / OpenCL

Interface allowing R to use OpenCL
Other
15 stars 10 forks source link

Error during installation... #19

Closed aerickso closed 1 year ago

aerickso commented 1 year ago

Hi!

Thank you for responding to my previous issue.

I came back today to try again to install OpenCL.

As before: I'm a primary R user, and I would like to try GPU Parallelization for matrix calculations using an R front end with OpenCL. I have a Windows 11 PC, with a NVIDIA RTX 2070 Super GPU. I've performed steps 0-3 from here, eg, installation of updated drivers, CUDA.

I followed the updated INSTALL documentation.

Specifically I have:

  1. Loaded the vendor-supplied DLL "OpenCL.dll"
  2. Set the OCL environment variable to the root of the OpenCL SDK (in my case, CUDA/v12.1)

I can confirm that OpenCL.lib is located at "~/CUDA/v12.1/lib/x64/OpenCL.lib"

To implement the above I run the following, but am now presented with the following error output.

> Sys.setenv(OCL = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1")
> dyn.load("C:/Windows/System32/OpenCL.dll", FALSE, TRUE)
> install.packages("OpenCL")

Installing package into ‘C:/Users/erick/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘OpenCL’
installing the source package ‘OpenCL’

trying URL 'https://cran.rstudio.com/src/contrib/OpenCL_0.2-2.tar.gz'
Content type 'application/x-gzip' length 20881 bytes (20 KB)
downloaded 20 KB

* installing *source* package 'OpenCL' ...
** package 'OpenCL' successfully unpacked and MD5 sums checked
** using staged installation

 === configurig OpenCL for /x64 ==

 OCL=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1

OCL64LIB not set, assuming C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/OpenCL.lib
OCL32LIB not set, assuming C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x86/OpenCL.lib
OCLINC not set, assuming -IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include

 --- Compiling 64-bit ---
OCL=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1
PKG_CPPFLAGS=-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include
PKG_LIBS=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/OpenCL.lib

NOTE: make sure the run-time DLLs are on PATH!

** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

using C compiler: 'gcc.exe (GCC) 12.2.0'
gcc  -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include'    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c buffer.c -o buffer.o
gcc  -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include'    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c ocl.c -o ocl.o
gcc  -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include'    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c reg.c -o reg.o
gcc  -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include'    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c wrap.c -o wrap.o
gcc -shared -s -static-libgcc -o OpenCL.dll tmp.def buffer.o ocl.o reg.o wrap.o C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/OpenCL.lib -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.0/bin/x64 -lR
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: please report this bug
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'OpenCL'
* removing 'C:/Users/erick/AppData/Local/R/win-library/4.3/OpenCL'
Warning in install.packages :
  installation of package ‘OpenCL’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\erick\AppData\Local\Temp\RtmpkpsWXb\downloaded_packages’

If I'm interpreting the above correctly, it seems that I've configured OpenCL correctly, but there is an installation/build issue..? I updated RTools to RTools 4.3. Unsure if this issue may be related to the one here ?

After spending another couple of hours trying to parse these error messages, I still have not managed to successfully install OpenCL. I'm open minded and flexible how to proceed; would love a solution that "just works"! I can't imagine that I'm the only end user experience these installation issues.

Happy to provide further information, thanks for your help in advance.

Session info output if needed:

> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: Europe/Helsinki
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.3.0  fastmap_1.1.1   cli_3.6.1       htmltools_0.5.5
 [5] tools_4.3.0     rstudioapi_0.14 yaml_2.3.7      rmarkdown_2.23 
 [9] knitr_1.43      xfun_0.39       digest_0.6.31   rlang_1.1.1    
[13] evaluate_0.21 
s-u commented 1 year ago

@aerickso This is a known bug in the linker (binutils to be precise) that you are using and, yes, you did indeed link the upstream issue which is also includes the solution, i.e., you need to use pacman to upgrade binutils to the latest version which doesn't have the bug (you can try pacman -Syu to upgrade your entire toolchain). This is not really related to OpenCL itself, it's just a combination of the vendor's DLLs and the linker used.

s-u commented 1 year ago

FWIW msys2 just released binutils 2.41 so the fix is now in the released version (no need to use patches). Short story: if you have binutils 2.40 it is buggy and needs to be upgraded.