# Calling another library from CUDA.jl

**URL:** https://discourse.julialang.org/t/calling-another-library-from-cuda-jl/107981
**Category:** GPU
**Tags:** question
**Created:** [December 23, 2023, 6:33pm UTC](https://discourse.julialang.org/t/calling-another-library-from-cuda-jl/107981 "2023-12-23T18:33:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AshtonSBradley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashtonsbradley/32/11140_2.png) [@AshtonSBradley](https://discourse.julialang.org/u/AshtonSBradley)
#### Post date: [December 23, 2023, 6:33pm UTC](https://discourse.julialang.org/t/calling-another-library-from-cuda-jl/107981/1 "2023-12-23T18:33:19Z")

</div>

Hi all,

I want to call another library on the GPU (external to CUDA.jl) and have the rest of the code use the high level CUDA.jl array interface.

It this possible to call an external library from CUDA.jl?

Any advice greatly appreciated!

---

<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: [December 25, 2023, 7:46pm UTC](https://discourse.julialang.org/t/calling-another-library-from-cuda-jl/107981/2 "2023-12-25T19:46:09Z")

</div>

> [@AshtonSBradley](#):
>
> It this possible to call an external library from [CUDA.jl](https://juliahub.com/ui/Packages/CUDA)?

The ability to call external libraries is not a CUDA.jl feature, but a property of Julia. If you can use any of the FFI interfaces (like `ccall`) to call this library, then yes. There is one consideration though, namely whether GPU data can be shared between Julia/CUDA.jl and your external library. For this, CUDA.jl uses the “primary” context to allocate data in, and should be compatible with other libraries using the same context.
