# CUDAnative on macOS X

**URL:** <https://discourse.julialang.org/t/cudanative-on-macos-x/2671>\
**Category:** GPU\
**Created:** [March 15, 2017, 10:10am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671 "2017-03-15T10:10:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 15, 2017, 10:10am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/1 "2017-03-15T10:10:43Z")

</div>

Did anyone manage to get CUDAnative running on macOS X?

I could successfully install CUDAdrv …

```julia
push!(Libdl.DL_LOAD_PATH, "/usr/local/cuda/lib")
Pkg.add("CUDAdrv")

```

… but trying to add CUDAnative fails with LLVM errors: `llvm-config not found`.

Any idea?

---

<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:** [March 15, 2017, 1:24pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/2 "2017-03-15T13:24:28Z")

</div>

Did you install CUDAnative according to the README or the recent blogpost? Because you need to compile Julia from source, or `llvm-config` and others will be missing.

That push to `DL_LOAD_PATH` shouldn’t be necessary, in sofar that directory is indexed by your library loader. Doesn’t macOS have something like `ld.so.conf`? CUDAdrv just uses `Libdl.find_library`.

(You might also want to post stuff about CUDAnative in Domains/GPU, which I’m watching for new posts.)

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 16, 2017, 9:29am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/3 "2017-03-16T09:29:37Z")

</div>

No, I did **not** compile Julia from source - I tried to use a local `llvm` installation (built from source), but that didn’t work.

`libcuda` isn’t found (in the default location). This is because on macOS X 10.12+ the DYLD\_LIBRARY\_PATH environment can **not** be set without disabling System Integrity Protection (rootless).

```julia
julia> Libdl.find_library("libcuda")
""

julia> push!(Libdl.DL_LOAD_PATH, "/usr/local/cuda/lib")
3-element Array{String,1}:
 "@loader_path/julia" 
 "@loader_path"       
 "/usr/local/cuda/lib"

julia> Libdl.find_library("libcuda")
"libcuda"

```

---

<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:** [March 16, 2017, 10:05am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/4 "2017-03-16T10:05:52Z")

</div>

> [@jheinen](#):
>
> No, I did **not** compile Julia from source - I tried to use a local llvm installation (built from source), but that didn’t work.

Right, not sure why you’re expecting it to work then. The LLVM library _really_ needs to be not only identical (for code generation compatibility), but the very same one loaded by Julia (because of [unresolved OSX issues](https://github.com/maleadt/LLVM.jl/blob/6b728a83af8f3464e511d05fff79bbd8969806af/deps/build.jl#L10-L25)).

---

<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:** [March 17, 2017, 8:29am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/5 "2017-03-17T08:29:57Z")

</div>

Seeing how `/usr/local/cuda/lib` seems like a popular, but non-indexed location of CUDA libraries, I’ve [added](https://github.com/JuliaGPU/CUDAdrv.jl/pull/21/files) it to the default search locations of CUDAdrv’s build script. So you won’t need to manually populate `Libdl.DL_LOAD_PATH` anymore (as soon as a new version is released).

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 17, 2017, 8:35am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/6 "2017-03-17T08:35:24Z")

</div>

Great! Thanks. 🙂

---

<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:** [March 17, 2017, 9:21am UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/7 "2017-03-17T09:21:25Z")

</div>

You’re welcome. Let me know if you run into other issues: macOS is supposed to be a supported platform, but lacking hardware (both personal and for CI) it’s possible that issues have crept in.

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 17, 2017, 1:48pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/8 "2017-03-17T13:48:39Z")

</div>

I built Julia 0.6 from source and could successfully add `CUDAnative` on `macOS X 10.12.4 Beta` with `CUDA 8.0`. Examples are working …

**Now, It’s up to Apple! Will they offer NVIDIA graphics cards for future iMacs or MacBooks?**

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [March 17, 2017, 3:37pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/9 "2017-03-17T15:37:25Z")

</div>

I learned to be very pessimistic about Apple and GPU support … And nobody will be able to tell you, since they don’t talk about what they plan to do! -.-

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 17, 2017, 4:06pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/10 "2017-03-17T16:06:20Z")

</div>

… I probably should have bought some MacBooks or iMacs with NVIDIA chipsets ahead 😉

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [March 17, 2017, 4:17pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/11 "2017-03-17T16:17:20Z")

</div>

Well, if we would support OpenCL as well, it would be less of an issue! 🙂  
But Apple will still be annoying to deal with because of how they try to push Metal against all industry standards -.-

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 17, 2017, 4:37pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/12 "2017-03-17T16:37:37Z")

</div>

> **[Next-generation 3D Graphics on the Web](https://webkit.org/blog/7380/next-generation-3d-graphics-on-the-web/)**
>
> Apple’s WebKit team today proposed a new Community Group at the W3C to discuss the future of 3D graphics on the Web, and to develop a standard API that exposes modern GPU features including low-level graphics and general purpose computation.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [March 17, 2017, 4:47pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/13 "2017-03-17T16:47:22Z")

</div>

Cool, would be nice to see more of that! The web world is quite different anyways, though…  
I’m just salty about how apple treats Vulkan 😃

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [March 17, 2017, 6:05pm UTC](https://discourse.julialang.org/t/cudanative-on-macos-x/2671/14 "2017-03-17T18:05:54Z")

</div>

Yes, I agree. Not to understand as Apple publishes the base sources for the macOS X run-time system (and supports a lot of OpenSource software) …
