s-u / OpenCL

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

Set up R OpenCL with an AMD GPU on Windows #15

Closed Quirinms closed 1 year ago

Quirinms commented 1 year ago

I already installed the R package OpenCL with a Nvidia GPU (GTX 1050 Ti) and the Nvidia toolkit on Windows. Now I am trying to set up R OpenCL for an AMD GPU (Radeon 7900 XTX) on Windows.

I installed the appropriate drivers for the AMD GPU from the official website and downloaded the AMD SDK and set up the OCL environment variable to "C:\Program Files (x86)\AMD APP SDK\3.0". Then I tried to install the OpenCL package with install.packages("OpenCL", INSTALL_opts = '--no-test-load') and install.packages("OpenCL", INSTALL_opts = c('--no-clean-on-error', '--no-test-load')). The compilation failed.

Screenshot (9)

The following message "OCL64LIB not set, assuming C:/Program Files (x86)/AMD APP SDK/3.0/lib/x64/OpenCL.lib OCL32LIB not set, assuming C:/Program Files (x86)/AMD APP SDK/3.0/lib/x86/OpenCL.lib OCLINC not set, assuming -IC:/Program Files (x86)/AMD APP SDK/3.0/include" made me wonder, if the paths could be wrong and indeed, there are paths "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86" and "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64". I dont know, why there is a x86_x64 instead of an expected x64, but R will not find the right way for x64 with the previous assumption.

Setting the paths directly to the files didnt work. Renaming the AMD APP SDK directory does result in a seemingly successful building of the package, but OpenCL code, which could be used before (on the Nvidia GPU) was not working due to OpenCL errors. Also, only the CPU built-in GPU with the was recognized by OpenCL and not the AMD GPU.

Screenshot (11)

s-u commented 1 year ago

@Quirinms Sorry, but what is you question? Your simply describing how you successfully installed OpenCL, which is great. The only issue I can see is that you tested it with some OpenCL code that is not supported by the AMD driver and/or your GPU. That has nothing to do with the OpenCL package (and you didn't post the code nor the errors) so I'm not sure what is the issue you're reporting.

Quirinms commented 1 year ago

The question is: how to set up OpenCL in R in a way, so that it recognizes the AMD GPU? Was something wrong in my set up? Was the "trick" I did not valid? Is it a driver issue that OpenCL in R does not recognize the AMD GPU?

aaronpuchert commented 1 year ago

Does the GPU show up in the output of clinfo? And can you compare that with the output of

lapply(oclPlatforms(), oclInfo)
lapply(oclDevices(), oclInfo)

in R?

Quirinms commented 1 year ago

The GPU does show up in the output of clinfo, but not in the oclDevices():

OpenCL::oclDevices() [[1]] OpenCL device 'Intel(R) UHD Graphics 770'

lapply(oclPlatforms(), oclInfo) [[1]] [[1]]$name [1] "Intel(R) OpenCL HD Graphics"

[[1]]$vendor [1] "Intel(R) Corporation"

[[1]]$version [1] "OpenCL 3.0 "

[[1]]$profile [1] "FULL_PROFILE"

[[1]]$exts [1] "cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_command_queue_families cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_intel_device_attribute_query cl_khr_suggested_local_work_size cl_intel_spirv_media_block_io cl_intel_spirv_subgroups cl_khr_spirv_no_integer_wrap_decoration cl_intel_unified_shared_memory_preview cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_intel_planar_yuv cl_intel_packed_yuv cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_khr_gl_sharing cl_khr_gl_depth_images cl_khr_gl_event cl_khr_gl_msaa_sharing cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_intel_d3d11_nv12_media_sharing cl_intel_sharing_format_query cl_khr_pci_bus_info cl_intel_subgroup_local_block_io cl_intel_simultaneous_sharing "

[[2]] [[2]]$name [1] "AMD Accelerated Parallel Processing"

[[2]]$vendor [1] "Advanced Micro Devices, Inc."

[[2]]$version [1] "OpenCL 2.1 AMD-APP (3504.0)"

[[2]]$profile [1] "FULL_PROFILE"

[[2]]$exts [1] "cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices "

lapply(oclDevices(), oclInfo) [[1]] [[1]]$name [1] "Intel(R) UHD Graphics 770"

[[1]]$vendor [1] "Intel(R) Corporation"

[[1]]$version [1] "OpenCL 3.0 NEO "

[[1]]$profile [1] "FULL_PROFILE"

[[1]]$exts [1] "cl_khr_byte_addressable_store" "cl_khr_fp16"
[3] "cl_khr_global_int32_base_atomics" "cl_khr_global_int32_extended_atomics"
[5] "cl_khr_icd" "cl_khr_local_int32_base_atomics"
[7] "cl_khr_local_int32_extended_atomics" "cl_intel_command_queue_families"
[9] "cl_intel_subgroups" "cl_intel_required_subgroup_size"
[11] "cl_intel_subgroups_short" "cl_khr_spir"
[13] "cl_intel_accelerator" "cl_intel_driver_diagnostics"
[15] "cl_khr_priority_hints" "cl_khr_throttle_hints"
[17] "cl_khr_create_command_queue" "cl_intel_subgroups_char"
[19] "cl_intel_subgroups_long" "cl_khr_il_program"
[21] "cl_intel_mem_force_host_memory" "cl_khr_subgroup_extended_types"
[23] "cl_khr_subgroup_non_uniform_vote" "cl_khr_subgroup_ballot"
[25] "cl_khr_subgroup_non_uniform_arithmetic" "cl_khr_subgroup_shuffle"
[27] "cl_khr_subgroup_shuffle_relative" "cl_khr_subgroup_clustered_reduce"
[29] "cl_intel_device_attribute_query" "cl_khr_suggested_local_work_size"
[31] "cl_intel_spirv_media_block_io" "cl_intel_spirv_subgroups"
[33] "cl_khr_spirv_no_integer_wrap_decoration" "cl_intel_unified_shared_memory_preview" [35] "cl_khr_mipmap_image" "cl_khr_mipmap_image_writes"
[37] "cl_intel_planar_yuv" "cl_intel_packed_yuv"
[39] "cl_khr_int64_base_atomics" "cl_khr_int64_extended_atomics"
[41] "cl_khr_image2d_from_buffer" "cl_khr_depth_images"
[43] "cl_khr_3d_image_writes" "cl_intel_media_block_io"
[45] "cl_khr_gl_sharing" "cl_khr_gl_depth_images"
[47] "cl_khr_gl_event" "cl_khr_gl_msaa_sharing"
[49] "cl_khr_d3d10_sharing" "cl_khr_d3d11_sharing"
[51] "cl_intel_d3d11_nv12_media_sharing" "cl_intel_sharing_format_query"
[53] "cl_khr_pci_bus_info" "cl_intel_subgroup_local_block_io"
[55] "cl_intel_simultaneous_sharing"

[[1]]$driver.ver [1] "30.0.101.1273"

[[1]]$max.frequency [1] 1500

s-u commented 1 year ago

You only asked for device in the Intel platform. If you want the AMD device, you have to use the AMD platform (see documentation).

aaronpuchert commented 1 year ago

Indeed, I should have asked you to run lapply(oclPlatforms(), oclDevices) or lapply(lapply(oclPlatforms(), oclDevices), oclInfo). So you'll need a device provided by oclDevices(oclPlatforms()[[2]]).

Quirinms commented 1 year ago

oclDevices(oclPlatforms()[[2]]) [[1]] OpenCL device 'gfx1100'

aaronpuchert commented 1 year ago

Can't find an official source, but it seems that GFX1100 stands for RDNA 3 Navi 31, marketed as "Radeon RX 7900 XT[X]". So that should be the card that you're looking for.