# Using CuSparseMatrixCSR

**URL:** <https://discourse.julialang.org/t/using-cusparsematrixcsr/94379>\
**Category:** GPU\
**Tags:** question\
**Created:** [February 9, 2023, 9:54pm UTC](https://discourse.julialang.org/t/using-cusparsematrixcsr/94379 "2023-02-09T21:54:16Z")\
**Posts on this page:** 2\
**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:** [February 9, 2023, 9:54pm UTC](https://discourse.julialang.org/t/using-cusparsematrixcsr/94379/1 "2023-02-09T21:54:16Z")

</div>

Hi,

Based on the [CUDA.jl github](https://github.com/JuliaGPU/CUDA.jl/blob/master/lib/cusparse/array.jl#L71) I tried to create a CuSparseMatrixCSR matrix. I’m sparing the loading of the data, all of the values I input in are defined.

```julia
using CUDA

export CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixBSR, CuSparseMatrixCOO,

CuSparseMatrix, AbstractCuSparseMatrix,

CuSparseVector,

CuSparseVecOrMat

using LinearAlgebra: BlasFloat

using SparseArrays: nonzeroinds, dimlub

nnzJ = length(vals)

N = length(rows)-1

M = length(vec)

rows_d = CuVector{Int64}(rows)

cols_d = CuVector{Int64}(cols)

vals_d = CuVector{Float64}(vals)

dims::NTuple{2,Int64} = (N,M)

A = CuSparseMatrixCSR{Int64, Float64}(rows_d, cols_d, vals_d, dims, nnzJ)

```

Most of these I included just because I saw them in the file and wanted to be safe. I got

```julia
LoadError: UndefVarError: `CuSparseMatrixCSR` not defined

```

on the final line. Any ideas on how to fix this?

Thanks!

---

<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:** [February 9, 2023, 11:09pm UTC](https://discourse.julialang.org/t/using-cusparsematrixcsr/94379/2 "2023-02-09T23:09:35Z")

</div>

Resolved

```julia
using CUDA.CUSPARSE

```
