cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

ccm
Journeyman III

from python to pyopencl code need help

Greetings to all AMD Dev community,

I am a beginner in need of help.  I am learning OpenCL and trying run some python code on the GPU. The code runs fine on CPU but it takes days. I want to run that code on my AMD GPU (RX580 8Gb).

This is the Python code:

import numpy as np
num = 0; nummax = 0
while num <= 44:
    n = np.random.randint(low=1, high=51, size=(9,5))
    num = len(np.unique(n))
    if num > nummax: nummax = num
    print(nummax, num)
n.sort()
print(nummax, n, sep='\n')

What I have already tried?

  • I have successfully run the python code on one CPU core and also using all CPU Core (with Numba ROCm) but could not run it on GPU 
  • First I have spent some time learning Python Numba with no success (because my code need  numpy.random.randint  and Numba does not have full implementation, only partial)
  • then I have spent some time learning pyopencl on Hands On OpenCL by HandsOnOpenCL studying the examples and solutions but, I must confess, could not implement my simple code but i can run all OpenCL code of the examples and exercises (that means my OpenCL software and hardware are correctly installed and configured to run OpenCL code). 

 

What hardware/software I have:

  • uname -a : Linux rig1 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • inxi -Gx: Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: ASUSTeK, Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: ASUSTeK , Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: ASUSTeK , OpenGL: renderer: Radeon RX 580 Series (POLARIS10 DRM 3.35.0 5.4.0-26-generic LLVM 11.0.0) v: 4.6 Mesa 20.2.6
  • clinfo | grep compute: Max compute units 36, SIMD per compute unit (AMD) 4, Max real-time compute units (AMD) 0, Max real-time compute units (AMD) 0, Max compute units (INTEL) 4
  • dpkg -l | grep opencl: ocl-icd-libopencl1-amdgpu-pro:amd64 21.20-1271047, ocl-icd-libopencl1-amdgpu-pro:amd64 21.20-1271047, ocl-icd-libopencl1-amdgpu-pro:amd64 21.20-1271047, etc
  • dpkg -l | grep amdgpu: amdgpu-pro-core 21.20-1271047, amdgpu-dkms 1:5.11.5.26-1271047
  • AMD GPU Driver: amdgpu-pro-21.20-1271047-ubuntu-20.04.tar.xz installed with: ./amdgpu-pro --opencl=pal,legacy --headless

 

0 Likes
0 Replies