# Buggy code
def _check_cusolver_dev_info_if_synchronization_allowed(routine, dev_info):
    # `dev_info` contains a single integer, the status code of a cuSOLVER
    # routine call. It is referred to as "devInfo" in the official cuSOLVER
    # documentation.
    assert isinstance(dev_info, core.ndarray)
    assert dev_info.size == 1

    config_linalg = cupyx._ufunc_config.config.linalg
    # Only 'ignore' and 'raise' are currently supported.
    if config_linalg == "ignore":
        return

    assert config_linalg == "raise"
    dev_info_host = dev_info.item()
    if dev_info_host != 0:
        raise linalg.LinAlgError(
            "Error reported by {} in cuSOLVER. devInfo = {}. Please refer"
            " to the cuSOLVER documentation.".format(routine.__name__, dev_info_host)
        )


# Traceback (AttributeError)
Traceback (most recent call last):
File "cpu-svd.py", line 10, in <module>
u.compute()
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/base.py", line 165, in compute
(result,) = compute(self, traverse=False, **kwargs)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/base.py", line 436, in compute
results = schedule(dsk, keys, **kwargs)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/threaded.py", line 81, in get
**kwargs
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/local.py", line 486, in get_async
raise_exception(exc, tb)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/local.py", line 316, in reraise
raise exc
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/local.py", line 222, in execute_task
result = _execute_task(task, data)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/core.py", line 119, in _execute_task
return func(*args2)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/optimization.py", line 982, in __call__
return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/core.py", line 149, in get
result = _execute_task(task, cache)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/core.py", line 119, in _execute_task
return func(*args2)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/dask/array/linalg.py", line 48, in _wrapped_qr
return np.linalg.qr(a)
File "<__array_function__ internals>", line 6, in qr
File "cupy/core/core.pyx", line 1344, in cupy.core.core.ndarray.__array_function__
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/cupy/linalg/decomposition.py", line 248, in qr
geqrf, dev_info)
File "/datasets/bzaitlen/miniconda3/envs/rapids-12/lib/python3.7/site-packages/cupy/linalg/util.py", line 42, in _check_cusolver_dev_info_if_synchronization_allowed
print(cupyx._ufunc_config.config.linalg)
AttributeError: '_thread._local' object has no attribute 'linalg'

# Fixed code
def _check_cusolver_dev_info_if_synchronization_allowed(routine, dev_info):
    # `dev_info` contains a single integer, the status code of a cuSOLVER
    # routine call. It is referred to as "devInfo" in the official cuSOLVER
    # documentation.
    assert isinstance(dev_info, core.ndarray)
    assert dev_info.size == 1
    config_linalg = cupyx._ufunc_config.get_config_linalg()
    # Only 'ignore' and 'raise' are currently supported.
    if config_linalg == "ignore":
        return

    assert config_linalg == "raise"
    dev_info_host = dev_info.item()
    if dev_info_host != 0:
        raise linalg.LinAlgError(
            "Error reported by {} in cuSOLVER. devInfo = {}. Please refer"
            " to the cuSOLVER documentation.".format(routine.__name__, dev_info_host)
        )