Installing CUDA Toolkit on Mac without an NVIDIA GPU
This blog post describes how to install the CUDA Toolkit (i.e., the development tools, including shared libraries, the compiler, the nvidia visual profiler, the handy tools/CUDA_Occupancy_Calculator.xls, and so on) on a Mac without an NVIDIA GPU.
Macs with an NVIDIA GPU are now a dying species, with the latest Macbook Pros having switched to AMD discrete graphics cards for the past few years. This means that even if you install the CUDA development tools, you probably won’t be able to execute any CUDA code.
However, there are a few reasons why this is useful:
Development of code without having to access a remote machine. I basically work exclusively through an ssh connection to a linux machine from a mac laptop for my day-to-day work.
Use of CUDA’s GUI tools without suffering the lag of a remote connection. In particular, the NVIDIA Visual Profiler allows you to load the output of nvprof for analysis, allowing you to profile on a remote machine, but analyze locally. This is the number one reason why I figured out how to do this.
For example, you can dump statistics like this with nvprof:
nvprof --analysis-metrics -f -o warp-ctc.nvprof --print-gpu-trace <my-executable> <my-args>
scp it to your local machine, then open it with
nvvp warp-ctc.nvprof. Thanks to this blog post for telling me about this.
Download one of the disk images from the install site. Open it up. This will mount it under the directory /Volumes.
/Volumes/CUDAMacOSXInstaller.app/Contents/MacOS/CUDAMacOSXInstaller --no-window --silent --accept-eula --install-package=cuda-toolkit
Once it is done, your installation should sit in
To be clear here,specifically you are installing only the “toolkit”, which doesn’t contain the drivers. Hopefully this dispells the myth that you need an NVIDIA GPU to even have the CUDA development libraries on a Mac.