cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

edman007
Journeyman III

OpenCL/clCreateCommandQueue Fails with CL_OUT_OF_HOST_MEMORY on Vega 3 with Rocm

Hi,

So I'm trying to get OpenCL (really OpenCV) working on my Athlon 3000G With Vega 3. I'm running Debian Bullseye and put the Ubuntu Focal ROCm on (using the 5.18 amdgpu-pro kernel driver). `clinfo` shows both mesa and amdgpu pro drivers. My kernel is `Linux queenOfHearts 5.18.0-0.deb11.4-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.16-1~bpo11+1 (2022-08-12) x86_64 GNU/Linux`

 

Anyways, I'm trying to figure out why it's failing even though from what I understand it should work.

 

My Test program for now is just a simple hello world and it always fails at clCreateCommandQueue with  CL_OUT_OF_HOST_MEMORY

 

    int gpu = 0;
    err = clGetPlatformIDs(platform_insize, platforms, &platform_cnt);
    if (err != CL_SUCCESS)
    {
        printf("Error: Failed to get Platforms \n");
        
    }
    printf("Platforms: %d \n", platform_cnt);
    err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, 1, &device_id, NULL);
    if (err != CL_SUCCESS)
    {
        switch (err){
        case CL_INVALID_PLATFORM:
            printf("Error: Failed to create a device group! Platform \n");
            break;
        case CL_INVALID_DEVICE_TYPE :
            printf("Error: Failed to create a device group! Device \n");
            break;

        case CL_INVALID_VALUE:
            printf("Error: Failed to create a device group! value \n");
            break;

        case CL_DEVICE_NOT_FOUND:
            printf("Error: Failed to create a device group! not found \n");
            break;
        default:
            printf("Error: Failed to create a device group! %d \n", err);
        }
        return EXIT_FAILURE;
    }
  
    // Create a compute context 
    //
    context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
    if (!context)
    {
        printf("Error: Failed to create a compute context!\n");
        return EXIT_FAILURE;
    }

    // Create a command commands
    //
    commands = clCreateCommandQueue(context, device_id, 0, &err);
    if (!commands)
    {
        printf("Error: Failed to create a command commands! %d\n", err);
        switch (err){
        case CL_OUT_OF_HOST_MEMORY :
            printf("Error: Out of memory\n");
        }
        return EXIT_FAILURE;
    }

 Some other notes:

 

I'm building against the AMD source (`/opt/rocm/llvm/bin/clang -L/opt/rocm/lib/ -I/opt/rocm/include -lOpenCL ocl-test.c -o tocl`) and it still happens. When I run `clinfo`, it always prints an error at the bottom

 

Number of platforms:				 2
  Platform Profile:				 FULL_PROFILE
  Platform Version:				 OpenCL 2.1 AMD-APP (3486.0)
  Platform Name:				 AMD Accelerated Parallel Processing
  Platform Vendor:				 Advanced Micro Devices, Inc.
  Platform Extensions:				 cl_khr_icd cl_amd_event_callback 
  Platform Profile:				 FULL_PROFILE
  Platform Version:				 OpenCL 1.1 Mesa 20.3.5
  Platform Name:				 Clover
  Platform Vendor:				 Mesa
  Platform Extensions:				 cl_khr_icd


  Platform Name:				 AMD Accelerated Parallel Processing
Number of devices:				 1
  Device Type:					 CL_DEVICE_TYPE_GPU
  Vendor ID:					 1002h
  Board name:					 AMD Athlon 3000G with Radeon Vega Graphics
  Device Topology:				 PCI[ B#6, D#0, F#0 ]
  Max compute units:				 11
  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:			 6208954880
  Image support:				 Yes
  Max number of images read arguments:		 128
  Max number of images write arguments:		 8
  Max image 2D width:				 16384
  Max image 2D height:				 16384
  Max image 3D width:				 16384
  Max image 3D height:				 16384
  Max image 3D depth:				 8192
  Max samplers within kernel:			 5592
  Max size of kernel argument:			 1024
  Alignment (bits) of base address:		 1024
  Minimum alignment (bytes) for any datatype:	 128
  Single precision floating point capability
    Denorms:					 Yes
    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:					 0
  Global memory size:				 7304652800
  Constant buffer size:				 6208954880
  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:				 1913987584
  Max global variable size:			 6208954880
  Max global variable preferred total size:	 7304652800
  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:				 Yes
    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:					 0x7f9f08f6ee50
  Name:						 gfx902:xnack+
  Vendor:					 Advanced Micro Devices, Inc.
  Device OpenCL C version:			 OpenCL C 2.0 
  Driver version:				 3486.0 (HSA1.1,LC)
  Profile:					 FULL_PROFILE
  Version:					 OpenCL 2.0 
  Extensions:					 cl_khr_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_amd_device_attribute_query cl_amd_media_ops cl_amd_media_ops2 cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_depth_images cl_amd_copy_buffer_p2p cl_amd_assembly_program 


  Platform Name:				 Clover
Number of devices:				 1
  Device Type:					 CL_DEVICE_TYPE_GPU
  Vendor ID:					 1002h
  Max compute units:				 3
  Max work items dimensions:			 3
    Max work items[0]:				 256
    Max work items[1]:				 256
    Max work items[2]:				 256
  Max work group size:				 256
  Preferred vector width char:			 16
  Preferred vector width short:			 8
  Preferred vector width int:			 4
  Preferred vector width long:			 2
  Preferred vector width float:			 4
  Preferred vector width double:		 2
  Native vector width char:			 16
  Native vector width short:			 8
  Native vector width int:			 4
  Native vector width long:			 2
  Native vector width float:			 4
  Native vector width double:			 2
  Max clock frequency:				 1100Mhz
  Address bits:					 64
  Max memory allocation:			 5113256960
  Image support:				 No
  Max size of kernel argument:			 1024
  Alignment (bits) of base address:		 32768
  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:				 No
    Round to +ve and infinity:			 No
    IEEE754-2008 fused multiply-add:		 No
  Cache type:					 None
  Cache line size:				 0
  Cache size:					 0
  Global memory size:				 7304652800
  Constant buffer size:				 67108864
  Max number of constant args:			 16
  Local memory type:				 Scratchpad
  Local memory size:				 32768
ERROR: clBuildProgram(-11)

 

Also, I always get a message in `dmesg`

 

`amdgpu: Alloc host visible vram on small bar is not allowed`

 

Also, during boot and some other tests I had these kernel messages pop up:

 

[   39.365458] ------------[ cut here ]------------
[   39.365466] refcount_t: decrement hit 0; leaking memory.
[   39.365477] WARNING: CPU: 0 PID: 6 at lib/refcount.c:31 refcount_warn_saturate+0xfb/0x110
[   39.365496] Modules linked in: xt_conntrack nft_chain_nat xt_MASQUERADE nf_nat nf_conntrack_netlink nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xfrm_user xfrm_algo xt_addrtype nft_compat n
f_tables libcrc32c nfnetlink br_netfilter bridge stp llc rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache netfs binfmt_misc overlay intel_rapl_msr intel_rapl_common edac_mce_amd nls_ascii nls_
cp437 vfat fat kvm irqbypass ghash_clmulni_intel snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel joydev snd_intel_dspcfg snd_intel_sdw_acpi aesni_i
ntel snd_hda_codec crypto_simd cryptd snd_hda_core rapl snd_hwdep wmi_bmof snd_pcm snd_timer pcspkr snd cdc_acm ccp soundcore rng_core sp5100_tco sg watchdog k10temp efi_pstore evdev acpi_cp
ufreq msr nfsd parport_pc auth_rpcgss nfs_acl ppdev lockd lp grace parport fuse sunrpc configfs efivarfs ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic hid_generic usbhid 
hid dm_mod sd_mod t10_pi amdgpu(OE) crc64_rocksoft
[   39.365605]  crc64 crc_t10dif crct10dif_generic amddrm_ttm_helper(OE) amdttm(OE) xhci_pci amd_sched(OE) xhci_hcd amdkcl(OE) i2c_algo_bit drm_dp_helper usbcore ahci cec r8169 crct10dif_pcl
mul rc_core libahci realtek mdio_devres crct10dif_common crc32_pclmul drm_kms_helper libphy libata drm i2c_piix4 crc32c_intel scsi_mod usb_common scsi_common wmi video gpio_amdpt gpio_generi
c button
[   39.365641] CPU: 0 PID: 6 Comm: kworker/0:0 Tainted: G           OE     5.18.0-0.deb11.4-amd64 #1  Debian 5.18.16-1~bpo11+1
[   39.365645] Hardware name: Gigabyte Technology Co., Ltd. B450M DS3H/B450M DS3H-CF, BIOS F50 11/27/2019
[   39.365648] Workqueue: kfd_process_wq kfd_process_wq_release [amdgpu]
[   39.365929] RIP: 0010:refcount_warn_saturate+0xfb/0x110
[   39.365935] Code: f8 09 97 b0 c6 05 8c 95 58 01 01 e8 27 de 46 00 0f 0b e9 78 34 71 00 48 c7 c7 c8 09 97 b0 c6 05 73 95 58 01 01 e8 0d de 46 00 <0f> 0b e9 5e 34 71 00 66 66 2e 0f 1f 84 00
 00 00 00 00 0f 1f 00 8b
[   39.365937] RSP: 0018:ffffb7af00073de8 EFLAGS: 00010282
[   39.365940] RAX: 0000000000000000 RBX: ffff990c4b763100 RCX: 0000000000000000
[   39.365942] RDX: 0000000000000001 RSI: ffffffffb095cc7d RDI: 00000000ffffffff
[   39.365944] RBP: ffff990c4a478000 R08: 0000000000000000 R09: 00000000ffffdfff
[   39.365946] R10: ffffb7af00073c10 R11: ffff990f5f2c03e8 R12: 0000000000000001
[   39.365948] R13: ffff990c50362800 R14: ffff990c50362c00 R15: ffffd7aeff609405
[   39.365950] FS:  0000000000000000(0000) GS:ffff990f50800000(0000) knlGS:0000000000000000
[   39.365952] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   39.365954] CR2: 00007f0de0b35000 CR3: 0000000106c96000 CR4: 00000000003506f0
[   39.365956] Call Trace:
[   39.365960]  <TASK>
[   39.365962]  put_pasid_state_wait+0xa1/0xb0
[   39.365971]  ? mmu_notifier_unregister+0xb3/0xe0
[   39.365978]  amd_iommu_unbind_pasid+0xa8/0xd0
[   39.365981]  kfd_iommu_unbind_process+0x4b/0x60 [amdgpu]
[   39.366204]  kfd_process_wq_release+0x205/0x370 [amdgpu]
[   39.366424]  process_one_work+0x1e5/0x3b0
[   39.366431]  worker_thread+0x50/0x3a0
[   39.366434]  ? rescuer_thread+0x390/0x390
[   39.366437]  kthread+0xe7/0x110
[   39.366440]  ? kthread_complete_and_exit+0x20/0x20
[   39.366442]  ret_from_fork+0x22/0x30
[   39.366449]  </TASK>
[   39.366450] ---[ end trace 0000000000000000 ]---
[  242.629395] INFO: task kworker/3:0:32 blocked for more than 120 seconds.
[  242.629403]       Tainted: G        W  OE     5.18.0-0.deb11.4-amd64 #1 Debian 5.18.16-1~bpo11+1
[  242.629412] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  242.629419] task:kworker/3:0     state:D stack:    0 pid:   32 ppid:     2 flags:0x00004000
[  242.629426] Workqueue: kfd_process_wq kfd_process_wq_release [amdgpu]
[  242.629796] Call Trace:
[  242.629797]  <TASK>
[  242.629800]  __schedule+0x308/0x9f0
[  242.629808]  schedule+0x4e/0xb0
[  242.629813]  put_pasid_state_wait+0x6f/0xb0
[  242.629818]  ? dequeue_task_stop+0x70/0x70
[  242.629825]  amd_iommu_unbind_pasid+0xa8/0xd0
[  242.629830]  kfd_iommu_unbind_process+0x4b/0x60 [amdgpu]
[  242.630212]  kfd_process_wq_release+0x205/0x370 [amdgpu]
[  242.630580]  process_one_work+0x1e5/0x3b0
[  242.630587]  worker_thread+0x50/0x3a0
[  242.630592]  ? rescuer_thread+0x390/0x390
[  242.630596]  kthread+0xe7/0x110
[  242.630600]  ? kthread_complete_and_exit+0x20/0x20
[  242.630604]  ret_from_fork+0x22/0x30
[  242.630613]  </TASK>

 

and when I try opencv and try to use a UMat I get:

 

`[ERROR:0] global ../modules/core/src/ocl.cpp (997) getInitializedExecutionContext OpenCL: Can't create default OpenCL queue`

Does anyone know what's going on here...I think I have it installed right, is there some support that my GPU is lacking? Is there something else that I'm missing?

0 Likes
1 Reply
dipak
Big Boss

Hi @edman007 ,

Thank you for reaching out. As per the list of supported hardware mentioned in the ROCm-Release-Notes-v5.3, it looks like this GPU is not supported on ROCm. 

Please note, ROCm related support is provided at its GitHub site itself. You can use the following link to post any query or issue related to ROCm: https://github.com/RadeonOpenCompute/ROCm/issues

Thanks.

0 Likes