Install OpenCL 2.0 driver for AMD GPU on Ubuntu 19.10? What's my options?

7,883

At last, I make it works and here is the result from clinfo (binary bundled from ROCm).

umber of platforms:              1
  Platform Profile:              FULL_PROFILE
  Platform Version:              OpenCL 2.1 AMD-APP (3004.6)
  Platform Name:                 AMD Accelerated Parallel Processing
  Platform Vendor:               Advanced Micro Devices, Inc.
  Platform Extensions:               cl_khr_icd cl_amd_event_callback cl_amd_offline_devices 


  Platform Name:                 AMD Accelerated Parallel Processing
Number of devices:               1
  Device Type:                   CL_DEVICE_TYPE_GPU
  Vendor ID:                     1002h
  Board name:                    Unknown AMD GPU
  Device Topology:               PCI[ B#7, D#0, F#0 ]
  Max compute units:                 8
  Max work items dimensions:             3
    Max work items[0]:               1024
    Max work items[1]:               1024
    Max work items[2]:               1024
  Max work group size:               256
  Preferred vector width char:           4
  Preferred vector width short:          2
  Preferred vector width int:            1
  Preferred vector width long:           1
  Preferred vector width float:          1
  Preferred vector width double:         1
  Native vector width char:          4
  Native vector width short:             2
  Native vector width int:           1
  Native vector width long:          1
  Native vector width float:             1
  Native vector width double:            1
  Max clock frequency:               1100Mhz
  Address bits:                  64
  Max memory allocation:             1825361100
  Image support:                 Yes
  Max number of images read arguments:       128
  Max number of images write arguments:      64
  Max image 2D width:                16384
  Max image 2D height:               16384
  Max image 3D width:                2048
  Max image 3D height:               2048
  Max image 3D depth:                2048
  Max samplers within kernel:            16
  Max size of kernel argument:           1024
  Alignment (bits) of base address:      2048
  Minimum alignment (bytes) for any datatype:    128
  Single precision floating point capability
    Denorms:                     No
    Quiet NaNs:                  Yes
    Round to nearest even:           Yes
    Round to zero:               Yes
    Round to +ve and infinity:           Yes
    IEEE754-2008 fused multiply-add:         Yes
  Cache type:                    Read/Write
  Cache line size:               64
  Cache size:                    16384
  Global memory size:                7301444400
  Constant buffer size:              1825361100
  Max number of constant args:           8
  Local memory type:                 Scratchpad
  Local memory size:                 65536
  Max pipe arguments:                16
  Max pipe active reservations:          16
  Max pipe packet size:              1825361100
  Max global variable size:          1642824960
  Max global variable preferred total size:  7301444400
  Max read/write image args:             64
  Max on device events:              1024
  Queue on device max size:          8388608
  Max on device queues:              1
  Queue on device preferred size:        262144
  SVM capabilities:              
    Coarse grain buffer:             Yes
    Fine grain buffer:               Yes
    Fine grain system:               No
    Atomics:                     No
  Preferred platform atomic alignment:       0
  Preferred global atomic alignment:         0
  Preferred local atomic alignment:      0
  Kernel Preferred work group size multiple:     64
  Error correction support:          0
  Unified memory for Host and Device:        1
  Profiling timer resolution:            1
  Device endianess:              Little
  Available:                     Yes
  Compiler available:                Yes
  Execution capabilities:                
    Execute OpenCL kernels:          Yes
    Execute native function:             No
  Queue on Host properties:              
    Out-of-Order:                No
    Profiling :                  Yes
  Queue on Device properties:                
    Out-of-Order:                Yes
    Profiling :                  Yes
  Platform ID:                   0x7f6233d65f10
  Name:                      gfx902
  Vendor:                    Advanced Micro Devices, Inc.
  Device OpenCL C version:           OpenCL C 2.0 
  Driver version:                3004.6 (PAL,HSAIL)
  Profile:                   FULL_PROFILE
  Version:                   OpenCL 2.0 AMD-APP (3004.6)
  Extensions:                    cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_khr_gl_depth_images cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_gl_event cl_khr_depth_images cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_amd_copy_buffer_p2p

Let's catch up here a bit. Now my system is

  • Kernel version: 5.3.18 generic
  • Graphics API: Mesa (latest versions are fine)
  • OpenCL: 2.1 via ROCm 3.1 or whatever version it might give you from installing via apt command.

The point is after completing installation of ROCm. You have to download latest AMD driver. As of my writing it is version 19.50, the exact link is amdgpu-pro-19.50-967956-ubuntu-18.04.tar.xz. Don't worry about Ubuntu release version even you're at 19.10 like my case, the important thing might be to stay at kernel 5.3.x for safety that will suit both ROCm and AMD driver.

Then you use / modify the script from tuxutku here. You can comment out the line of downloading the remote file as you now download it yourself, then operate offline against such file in file system instead. Take good care of the last command which it will copy the result files into /. You can even comment that line and do it manually yourself for safety as well.

The catch from the script is that we don't really install anything from AMD driver package, but just take shared library, and a few config files out then place in our system. ROCm will interact with it. It involves renaming shared library to avoid conflict in case you have working AMDGPU-PRO installed already as well, so this will isolate the problem.

Remember that /opt/OpenCL/vendors/amdocl64.icd has libamdocl64.so as its content. We already copied the extracted .so file to / thus it will refer to it instead of ROCm's bundled .so file. If you refer to ROCm's, it won't work and will shout out error of no device found.

Now all done. You can verify all things by using separate binary of clinfo or the one bundled from ROCm to check if things went well.

Even better have some OpenCL-based applications to test it out. I use Phoronix test suite i.e. pts/juliagpu or pts/luxmark to test capability of OpenCL. For Blender, it detects and lists as following

enter image description here

Select the first one (unknown) seems to be true GPU for Blender, as selected the second one the Scene's setting of "GPU Compute" will grey out.

enter image description here

Yes, you need to make sure it is not greyed out to be sure that it's really GPU that render. Or you can use radeontop to monitor the activity when rendering the scene.

Lastly, although it works now and Blender detects my GPU. But the performance is worse than before of using CPU with a laggy loading when you click to render the scene. This Blender issue indicates that it only officially support proprietary driver. Thus next step would be trying to purely use AMDGPU-PRO and test things out, but you have to involve effort in properly switch between open source driver and closed one.

Update:

I summed up the solution as described above with some improvement to make it easily to do it in this video.

Share:
7,883

Related videos on Youtube

haxpor
Author by

haxpor

Updated on September 18, 2022

Comments

  • haxpor
    haxpor over 1 year

    My main goal is to make Blender 2.82a able to detect my system's GPU then use as OpenCL compute to fasten the time in rendering.

    The problem seems to be my Ubuntu distribution version is too high as I have 19.10 (with kernel 5.5.11-050511-lowlatency) + AMDGPU-PRO's OpenCL component can only officially support up to Ubuntu 18.04, same goes to ROCm.

    I did try install AMDGPU-PRO's OpenCL via its installation script targeting only OpenCL component (via --headless), and even manually install one by one package; all with no success. It is clear as stated, not support shown up in error message. I would like to try again with ROCm but its package seems to be large. With no pre-built package available for my distro, I guess it will fail the same.

    So what would be my options if going back to 18.04 would be a last resort in installing OpenCL driver for my GPU (APU from Ryzen 3 2200g to be exact, I have no discrete GPU) alongside already installed open-source OpenGL/Vulkan driver from Mesa ?

    Edit:

    In the mean time, I did what I can to test things out by installing OpenCL 1.1 via libclang-common-10-dev libclc-amdgcn libclc-dev libclc-r600 libllvm10 mesa-opencl-icd packages. It shows meaningful information via clinfo. But Blender still didn't detect any GPU as OpenCL device.

    Update 1:

    I tested with ROCm. With good reports from here, and here, it becomes clear Ubuntu release version of 19.10 should not be a problem, only just need a proper kernel version. Thus I reverted my kernel version back to 5.3.x (specifically use 5.3.18 generic as 5.3 is stated as a supported version for ROCm, and from the report).

    Note that I minimally install packages as stated in 2nd report link as ROCm packages are huge then follow the less of installation instruction from README.md of its github page. Although I'm on eoan and the package is from xenial, I do take the risk for now. All passed. I can validate via clinfo or its /opt/rocm-3.1.0/opencl/bin/x86_64/clinfo both give meaningful result that I now have OpenCL 2.1 but with NO device found!!!.

    Result from clinfo

    Number of platforms                               1
      Platform Name                                   AMD Accelerated Parallel Processing
      Platform Vendor                                 Advanced Micro Devices, Inc.
      Platform Version                                OpenCL 2.1 AMD-APP (3084.0)
      Platform Profile                                FULL_PROFILE
      Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices 
      Platform Host timer resolution                  1ns
      Platform Extensions function suffix             AMD
    
      Platform Name                                   AMD Accelerated Parallel Processing
    Number of devices                                 0
    
    NULL platform behavior
      clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  AMD Accelerated Parallel Processing
      clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   
      clCreateContext(NULL, ...) [default]            No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
      clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No devices found in platform
    
    ICD loader properties
      ICD loader Name                                 OpenCL ICD Loader
      ICD loader Vendor                               OCL Icd free software
      ICD loader Version                              2.2.11
      ICD loader Profile                              OpenCL 2.1
    

    Result from /opt/rocm-3.1.0/opencl/bin/x86_64/clinfo

    Number of platforms:                 1
      Platform Profile:              FULL_PROFILE
      Platform Version:              OpenCL 2.1 AMD-APP (3084.0)
      Platform Name:                 AMD Accelerated Parallel Processing
      Platform Vendor:               Advanced Micro Devices, Inc.
      Platform Extensions:               cl_khr_icd cl_amd_event_callback cl_amd_offline_devices 
    
    
      Platform Name:                 AMD Accelerated Parallel Processing
    ERROR: clGetDeviceIDs(-1)
    

    Asides testing with Blender still doesn't detect GPU, that's right as now I'm having a problem with device not found.

    I'm further investigating ...

    Update 2:

    Problem solved although performance is not good. See my answer of this question below.