0

I am tryin to use arrayfire with python.

I have an GTX550Ti and use opencl backend since I don't seem to get cuda working (don't know if compute version 2.1 of the 550Ti is too low for arrayfire). I try to free memory / arrays that are allocated using statement such as

import numpy as np
import arrayfire as af

arr_h = np.arange(2**15,dtype=np.complex64)
arr_d = af.np_to_af_array(arr_h)

af.free_device(arr_d)

the free_device complains and says it need a pointer. If I use either

af.free_device(arr_d.raw_ptr())

or

af.free_device(arr_d.device_ptr())

I get an error:

OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFFFFF

So.. what is the correct way to free memory?

Erik Thysell
  • 1,160
  • 1
  • 14
  • 31
  • Are you sure you need to free the memory? In the examples provided in arrayfire-python, they do not free anything. [Arrayfire-python examples](https://github.com/arrayfire/arrayfire-python/tree/devel/examples). – parallel highway Aug 31 '17 at 14:36
  • I am running a loop with many calls to `af.np_to_af_array` with varying sizes of the array. When I do this I get "RuntimeError: OpenCL Error (-4) : Memory Object Allocation Failure when calling clEnqueueWriteBuffer" even though the array do fit into the memory (after restarting the app and using the same size again it works) – Erik Thysell Aug 31 '17 at 14:46
  • Please create an issue on arrayfire-python's github page with a reproducible code. This should not be happening. – Pavan Yalamanchili Aug 31 '17 at 19:31

1 Answers1

1
af.free_device(devicepointer)

Frees a device object. But you are trying to free an array inside the device. I would try any of these:

arr_d = af.Array()
arr_d = None
del arr_d 
DarkZeros
  • 8,235
  • 1
  • 26
  • 36
  • 1
    This deletes the array, but arrayfire uses a caching memory manager. You should also probably add `af.device_gc()` to clean up the memory immediately. – Pavan Yalamanchili Aug 31 '17 at 19:30