When an error is encountered (incorrect arguments or some calculation error), ArrayFire will raise an exception. This exception contains a stacktrace on which arrayfire function is raising the error and what is the cause for it. For example, this code will raise an print an exception:
import arrayfire as af
x = af.randu(10)
y = af.randu(5)
try:
# Arrays have non-broadcastable shapes
res = x + y
catch Exception as e:
print(e)This may produce the following output
In function arithOpBroadcast
In file src\api\c\binary.cpp:81
Invalid dimension for argument 1
Expected: ((lshape[d] == rshape[d]) || (lshape[d] == 1 && rshape[d] > 1) || (lshape[d] > 1 && rshape[d] == 1))
0# af::exception::~exception in afcuda
1# af_bilateral in afcuda
2# af_bilateral in afcuda
3# af_add in afcuda
4# ffi_prep_go_closure in libffi_8
5# ffi_call_go in libffi_8
6# ffi_call in libffi_8
7# 0x00007FFCD2833C05 in _ctypes
8# 0x00007FFCD2832ACA in _ctypes
9# 0x00007FFCD28326C8 in _ctypesFor issues with specific devices or memory limitations, ArrayFire provides functions to inform the user the current device and allocations.
For checking device information we have the functions:
- :doc:`get_device() <functions/get_device>` and :doc:`get_device_count()<functions/get_device_count>` gets the devices on the current backend
- :doc:`get_dbl_support(device_id)<functions/get_dbl_support>` and :doc:`get_half_support(device_id)<functions/get_half_support>` provides information for f64 and f16 type support
- :doc:`device_info(device_id)<functions/device_info>`, :doc:`info()<functions/info>`, :doc:`info_string()<functions/info_string>` provides backend, vendor, and version of device
- :doc:`device_gc()<functions/device_gc>` forces garbage collection of unused arrays on current device
- :doc:`get_mem_step_size()<functions/get_mem_step_size>` and :doc:`set_mem_step_size(mem_size)<functions/set_mem_step_size>` allows getting and setting the size of allocation groups
- :doc:`print_mem_info(prepend_message, device_id)<functions/print_mem_info>`: Print table of memory used by ArrayFire on the selected device
For internal information related to the kernels generated by the JIT, allocation triggers, and extra information, ArrayFire provides environment variables that enable extra tracing information that will be printed into stdout.
Please check the section of :doc:`Debugging Environment Variables in Configuring ArrayFire Environment<configuringarrayfireenvironment>` for a list of all the debug variables and their usage.
For outstanding issues related to ArrayFire, you may visit the Github Issues in ArrayFire Python and ArrayFire C/C++ Libraries