# Matrix inverse from device code

**URL:** <https://forums.developer.nvidia.com/t/matrix-inverse-from-device-code/178980>\
**Category:** CUDA Setup and Installation\
**Tags:** pycuda, kernel, python, cuda\
**Created:** [May 26, 2021, 8:20am UTC](https://forums.developer.nvidia.com/t/matrix-inverse-from-device-code/178980 "2021-05-26T08:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon74510222](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@anon74510222](https://forums.developer.nvidia.com/u/anon74510222)\
**Post date:** [May 26, 2021, 8:20am UTC](https://forums.developer.nvidia.com/t/matrix-inverse-from-device-code/178980/1 "2021-05-26T08:20:27Z")

</div>

Hi all,

I’m trying to parallelize an algorithm that needs to perform matrix inversion. Every thread will have a matrix of various size and I’m struggling to do batch processing, so I’d like to call the matrix inversion function directly from my kernel. Is there a way to do this? So far, my matrices always were hermitian, so I just implemented a Cholesky decomposition and diagonal inversion to perform the inversion, but I’m now dealing with regular non-singular matrices and I don’t want to implement the whole inversion function…  
I’m a bit confused about which external libraries I can use from device code… I heard about cuBLAS, but it seems ti be deprecated since Cuda 10.0, right…?

Thanks !

---

<div class="post-metadata">

**Author:** ![devesh37](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@devesh37](https://forums.developer.nvidia.com/u/devesh37)\
**Post date:** [June 23, 2021, 1:50pm UTC](https://forums.developer.nvidia.com/t/matrix-inverse-from-device-code/178980/2 "2021-06-23T13:50:56Z")

</div>

any work account. from last 1 month i am struggling with matrix inversion in kernal device code.  
Did you got any success??

---

<div class="post-metadata">

**Author:** ![anon74510222](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@anon74510222](https://forums.developer.nvidia.com/u/anon74510222)\
**Post date:** [June 25, 2021, 11:55am UTC](https://forums.developer.nvidia.com/t/matrix-inverse-from-device-code/178980/3 "2021-06-25T11:55:18Z")

</div>

No… But I figured out that my matrices were all positive semi-definite tho, so I implemented a Cholesky decomposition, and then the matrix inversion of the resulting diagonal matrices. Both are quite trivial to implement, but work only for very specific data. The question is still open.
