Memory Issue on OpenCL backend
shyams2 opened this issue · comments
I seem to be getting a memory error when using the OpenCL backend but passes fine when using the CPU backend:
>>> import arrayfire as af
>>> af.info()
ArrayFire v3.4.2 (OpenCL, 64-bit Linux, build 2da9967)
[0] INTEL : Intel(R) Xeon(R) CPU @ 2.50GHz, 30158 MB
>>> a = af.randu(200, 200, 200, 200, af.Dtype.f64)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/f2013305/anaconda3/lib/python3.6/site-packages/arrayfire-3.6.0-py3.6.egg/arrayfire/random.py", line 122, in randu
safe_call(backend.get().af_randu(c_pointer(out.arr), 4, c_pointer(dims), dtype.value))
File "/home/f2013305/anaconda3/lib/python3.6/site-packages/arrayfire-3.6.0-py3.6.egg/arrayfire/util.py", line 79, in safe_call
raise RuntimeError(to_str(err_str))
RuntimeError: In function virtual void* opencl::MemoryManager::nativeAlloc(size_t)
In file src/backend/opencl/memory.cpp:101
OpenCL Error (-61): Invalid Buffer Size when calling clCreateBuffer
>>> af.set_backend('cpu')
>>> a = af.randu(200, 200, 200, 200, af.Dtype.f64)
>>> af.print_mem_info()
Memory Info
---------------------------------------------------------
| POINTER | SIZE | AF LOCK | USER LOCK |
---------------------------------------------------------
| 0x7f8f111a4010 | 1.221e+04 MB | Yes | No |
| 0x180c0a0 | 1 KB | No | No |
---------------------------------------------------------
@ShyamSS-95 See if you can run clinfo
and show the output?
Number of platforms 1
Platform Name Intel(R) OpenCL
Platform Vendor Intel(R) Corporation
Platform Version OpenCL 1.2 LINUX
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd 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_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64
Platform Extensions function suffix INTEL
Platform Name Intel(R) OpenCL
Number of devices 1
Device Name Intel(R) Xeon(R) CPU @ 2.50GHz
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 1.2 (Build 25)
Driver Version 1.2.0.25
Device OpenCL C Version OpenCL C 1.2
Device Type CPU
Device Profile FULL_PROFILE
Max compute units 8
Max clock frequency 2500MHz
Device Partition (core)
Max number of sub-devices 8
Supported partition types by counts, equally, by names (Intel)
Max work item dimensions 3
Max work item sizes 8192x8192x8192
Max work group size 8192
Preferred work group size multiple 128
Preferred / native vector sizes
char 1 / 16
short 1 / 8
int 1 / 4
long 1 / 2
half 0 / 0 (n/a)
float 1 / 8
double 1 / 4 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 31623458816 (29.45GiB)
Error Correction support No
Max memory allocation 7905864704 (7.363GiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type Read/Write
Global Memory cache size 262144
Global Memory cache line 64 bytes
Image support Yes
Max number of samplers per kernel 480
Max size for 1D images from buffer 494116544 pixels
Max 1D or 2D image array size 2048 images
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 480
Max number of write image args 480
Local memory type Global
Local memory size 32768 (32KiB)
Max constant buffer size 131072 (128KiB)
Max number of constant args 480
Max size of kernel argument 3840 (3.75KiB)
Queue properties
Out-of-order execution Yes
Profiling Yes
Local thread execution (Intel) Yes
Prefer user sync for interop No
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
SPIR versions 1.2
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Available Yes
Compiler Available Yes
Linker Available Yes
Device Extensions cl_khr_icd 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_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) No platform
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) No platform
clCreateContext(NULL, ...) [default] No platform
clCreateContext(NULL, ...) [other] Success [INTEL]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) No platform
From clinfo:
Max memory allocation 7905864704 (7.363GiB)
This is a limitation of the Intel OpenCL driver.
@pavanky any idea whats the difference between Global memory size
and Max memory allocation
?:
Global memory size 31623458816 (29.45GiB)
Error Correction support No
Max memory allocation 7905864704 (7.363GiB)
On my machine, for the Intel CPU:
Global memory size 33547403264 (31.24GiB)
Error Correction support No
Max memory allocation 8386850816 (7.811GiB)
and for NVIDIA GPU:
Global memory size 2147352576 (2GiB)
Error Correction support No
Max memory allocation 536838144 (512MiB)
In particular, why is Max memory allocation
< Global memory size
? Does this mean the size of any one single buffer can't exceed Max memory allocation
?
@mchandra that's what it looks like. The documentation says the following:
Max size of memory object allocation in bytes. The minimum value is max (1/4th of CL_DEVICE_GLOBAL_MEM_SIZE, 128 * 1024 * 1024) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
Ok yes, that makes sense. Thanks!