Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Better error checking during initialization

Open
#51 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by tracing backend initialization from arrayfire.backend.name() through arrayfire.Array() and the safe_call path shown in the traceback. Confirm how device availability is currently checked and make the failure report a useful driver or device error; verify the behavior with the initialization scenario described in the issue.

Written by the indexing model from the issue text.

Description

Today I came across the following cryptic error message when trying to use arrayfire-python:


In [1]: import arrayfire
In [2]: arrayfire.backend.name()
Out[2]: 'cuda'
In [5]: arrayfire.Array()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-6dffbbbc7abd> in <module>()
----> 1 arrayfire.Array()

/home/filipe/.local/lib/python2.7/site-packages/arrayfire-3.2.20151211-py2.7.egg/arrayfire/array.pyc in __init__(self, src, dims, dtype, is_device)
    422             for n in range(numdims):
    423                 idims[n] = dims[n]
--> 424             self.arr = _create_empty_array(numdims, idims, to_dtype[type_char])
    425
    426     def as_type(self, ty):

/home/filipe/.local/lib/python2.7/site-packages/arrayfire-3.2.20151211-py2.7.egg/arrayfire/array.pyc in _create_empty_array(numdims, idims, dtype)
     36     c_dims = dim4(idims[0], idims[1], idims[2], idims[3])
     37     safe_call(backend.get().af_create_handle(ct.pointer(out_arr),
---> 38                                              numdims, ct.pointer(c_dims), dtype.value))
     39     return out_arr
     40

/home/filipe/.local/lib/python2.7/site-packages/arrayfire-3.2.20151211-py2.7.egg/arrayfire/util.pyc in safe_call(af_error)
     73         err_len = ct.c_longlong(0)
     74         backend.get().af_get_last_error(ct.pointer(err_str), ct.pointer(err_len))
---> 75         raise RuntimeError(to_str(err_str), af_error)
     76
     77 def get_version():

RuntimeError: ('Error in /var/lib/jenkins-slave/workspace/arrayfire-linux-mkl-graphics-installer/src/api/c/data.cpp(197):\n\n\n', 998)

The error was caused by a bad driver version:

$ nvidia-smi
Failed to initialize NVML: GPU access blocked by the operating system

I think it could be useful if arrayfire would test if a device is really available, instead of just checking if it can dlopen the relevant library. For example by calling arrayfire.Array(). If that would fail a more useful error could be returned to the user.

Dominant language
Python
Stars
422
Forks
63
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from arrayfire/arrayfire-python

All issues in arrayfire/arrayfire-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.