# Complete and incomplete sparse cholesky factorization

**URL:** https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918
**Category:** GPU
**Tags:** sparse
**Created:** [March 31, 2023, 11:04pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918 "2023-03-31T23:04:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)
#### Post date: [March 31, 2023, 11:04pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/1 "2023-03-31T23:04:39Z")

</div>

Say I have a CuSparseCSR matrix “A” and I want to take complete and incomplete cholesky factorizations of it, but crucially leave that factorization on the GPU, how can I do that?

Things I’ve tried:

1. CuSparse.jl - deprecated
2. CuArrays.jl - possibly deprecated, got this error trying to “add CuArrays” in the package manager

```julia
ERROR: Unsatisfiable requirements detected for package CUDAapi [3895d2a7]:
 CUDAapi [3895d2a7] log:
 ├─possible versions are: 0.5.0-4.0.0 or uninstalled
 └─restricted by julia compatibility requirements to versions: uninstalled — no versions left

```

1. Preconditioners.jl - only for CPU matrices
2. cholesky(A) - works but puts the factorization on the CPU

Is there a way to do this?

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [April 1, 2023, 7:03am UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/2 "2023-04-01T07:03:05Z")

</div>

CUSPARSE etc are now part of CUDA.jl, so just use the `CUDA.CUSPARSE` submodule.

For this specific functionality, you’d need to look in the sparse support of CUSOLVER, [cuSOLVER](https://docs.nvidia.com/cuda/cusolver/#cusolversp-sparse-lapack). I don’t think the library supports what you’re looking for.

---

<div class="post-metadata">

### Author: ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)
#### Post date: [April 3, 2023, 4:45pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/3 "2023-04-03T16:45:15Z")

</div>

Thanks, I’ll try that. It does seem odd though that Julia would have this incredibly important functionality like a GPU-based cholesky factorization and then get rid of it during updates

---

<div class="post-metadata">

### Author: ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)
#### Post date: [April 3, 2023, 4:58pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/4 "2023-04-03T16:58:25Z")

</div>

Based on your explanation here and [this](https://github.com/JuliaAttic/CUSPARSE.jl#example), I would expect to be able to use ic0 when `using CUDA.CUSPARSE`, but it says ic0 is undefined. Where did this functionality end up? I am also OK with a full factorization, my matrix is block diagonal anyways

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [April 3, 2023, 6:22pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/5 "2023-04-03T18:22:42Z")

</div>

> [@shakedregev](#):
>
> It does seem odd though that Julia would have this incredibly important functionality like a GPU-based cholesky factorization and then get rid of it during updates

I’m not sure what you’re suggesting here. If you do a quick search on `ic0` in the CUDA.jl repository you can find many functions. Nothing got deleted from the CUSPARSE package/module, but I’m not sure why you’re expecting the README instructions from a 5 year old package to work on a current version of CUDA.jl’s `CUSPARSE` module.

---

<div class="post-metadata">

### Author: ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)
#### Post date: [April 3, 2023, 6:45pm UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/6 "2023-04-03T18:45:22Z")

</div>

I don’t expect it to work as is, but I did expect there to be some way to do it, especially if you’re saying that nothing got deleted from the module (and it was possible 5 years ago). I’m specifically looking for complete or incomplete sparse csr gpu-based cholesky factorization (which you said in your first message is impossible in Julia, but definitely used to be possible)

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [April 4, 2023, 7:28am UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918/7 "2023-04-04T07:28:23Z")

</div>

> [@maleadt](#):
>
> I don’t think the library supports what you’re looking for.

> [@shakedregev](#):
>
> you said in your first message is impossible in Julia

You seem to have misunderstood my message. I’m not familiar with functionality you’re looking for, so I pointed you towards the CUSOLVER documentation. As you know what you are looking for, I recommend you take a look at the CUSOLVER/CUSPARSE docs to figure out which API calls you need. _Every_ CUDA API call is available in CUDA.jl, so it I can guarantee you we did not remove functionality (with the sole exception for APIs that are have been by NVIDIA). Whether there’s high-level functionality wrapping those APIs is another question.
