NVIDIA® CUDA Toolkit 11.0 no longer supports development or running applications on macOS. While there are no tools which use macOS as a target environment, NVIDIA is making macOS host versions of these tools that you can launch profiling and debugging sessions on supported target platforms.
Instructions for installing cuda-gdb on the macOS This tar archive holds the distribution of the CUDA 11.0 cuda-gdb debugger front-end for macOS. Native macOS debugging is not supported in this release, only remote debugging to other CUDA enabled targets. Version 9.2 of GDB, the GNU Debugger, is now available for download. See the ANNOUNCEMENT for details including changes in this release. An errata list and documentation are also available. News September 13th, 2020: GDB 10 branch created. The GDB 10 branch (gdb-10-branch) has been created. To check out a copy of the branch use. GDB: The GNU Project Debugger GDB Maintainers contributing current git documentation mailing lists Download GDB The most recent.
You may download all these tools here. Note that the Nsight tools provide the ability to download these macOS host versions on their respective product pages.
Install gdb via Homebrew: brew install gdb Restart taskgated: sudo killall taskgated && exit Reopen a Terminal window and type sudo codesign -vfs gdb.cert /usr/local/bin/gdb. This videos explains the step by step process to insall gdb debugger and gcc in windows 10. First of all you need to go to download page of minGW by clicking.
Please visit each tool's overview page for more information about the tool and its supported target platforms.
The macOS host tools provided are:
- Nsight Systems - a system profiler and timeline trace tool supporting Pascal and newer GPUs
- Nsight Compute - a CUDA kernel profiler supporting Volta and new GPUs
- Visual Profiler - a CUDA kernel and system profiler and timeline trace tool supporting older GPUs (see installation instructions, below)
- cuda-gdb - a GPU and CPU CUDA application debugger (see installation instructions, below)
Instructions for installing cuda-gdb on the macOS
- This tar archive holds the distribution of the CUDA 11.0 cuda-gdb debugger front-end for macOS.
Native macOS debugging is not supported in this release. Remote debugging from a macOS host to other CUDA enabled targets, however, is supported.
- To install:
- Create an installation directory
- INSTALL_DIR=$HOME/cuda-gdb-darwin-11.0
mkdir $INSTALL_DIR
cd $INSTALL_DIR - Download the cuda-gdb-darwin-11.0.tar.gz tar archive into $INSTALL_DIR above
- Unpack the tar archive
- tar fxvz cuda-gdb-darwin-11.0.tar.gz
- Add the bin directory to your path
- PATH=$INSTALL_DIR/bin:$PATH
- Run cuda-gdb --version to confirm you're picking up the correct binaries
- cuda-gdb --version
- Double click .dmg file to mount it and access it in finder.
- Drag nvvp folder and drop it to any location you want (say <nvvp_mac>).
Directory Structure:- |--nvvp
|--bin/
|--lib64/
|--libnvvp/ - Download and install the required version of JDK.
(Refer to the Notes about JRE Requirements when using Visual Profiler on the macOS section, below) - Open terminal.
- Change to the bin folder
- > cd <nvvp_mac>/nvvp/bin
- Run nvvp script file in command line
- > ./nvvp -vm <path_to_java>
- For example:
> ./nvvp -vm /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/bin/java - Remote profiling
- Import nvprof output files
- Download version: 8u144-b01 (Zulu: 8.23.0.3) .dmg.zip.tar.gz
- Download version: Zulu 8.23.0.3 (build 1.8.0_144-b01 .zip
- Open up Keychain Access
- Select Certificate Assistant -> Create a Certificate
- give it a name gdb-cert, type is self-signed root and Certificate Type is Code Signing. Finally, tick the Let me override defaults (this is important)
- It will warn you, you are about to create a certificate (because this might have been a shock) click continue
- For serial number and validity length, you can leave as, or change. then click continue
- The other certificate information can be left blank and just click continue
- 2048 Key size and Algorithm RSA which should be defaults just click continue
- Next 3 you can just click Continue
- Specify a Location, make sure you choose the Keychain option of System
You should see the following output:
- NVIDIA (R) CUDA Debugger
11.0 release
Portions Copyright (C) 2007-2020 NVIDIA Corporation
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
- Native macOS profiling is not supported in this release. Remote profiling from a macOS host to other CUDA enabled targets, however, is supported.
Supported Mac platforms: Mac OS X 10.13
- Steps to install:
- Steps to run:
- Summary of supported features:
- Refer the 'Visual Profiler' section in the 'Profiler User's Guide'
for more information:
- https://docs.nvidia.com/cuda/profiler-users-guide/index.html#visual
Notes about JRE Requirements when using Visual Profiler on the macOS
- OpenJDK provides an open-source (and standards compliant) implementation of a Java compliant JVM.
Binaries are provided by various vendors such as Oracle, Azul Systems (Zulu), Amazon, Red Hat, IBM, etc.
- Visual Profiler needs to use an older version of Java, specifically JRE update 151, to work correctly.
This is currently not offered by Oracle JDK but is provided by Azul Systems (Zulu).
- The Bazel Build project also uses the Zulu builds of OpenJDK.
- Download JDK 8.0.144 to get JRE update 151:
There comes a time when you want to step through your code, and breakpoints become useful. If you’re a PHP developer you reach out for Xdebug for example or it’s even built into some languages like recent versions of Python.
For many languages, the tool to reach to is gdb (GNU Project Debugger) it supports a wide range of languages including C++ and in my case Rust.
Indeed its as close to “official” debugger as you can get for Rust to the point the official install of rust has a rust-gdb wrapper to prettify the output. So installing it will be easy right?
it’s surely just
Well that certainly gets you a binary… not a working binary at least not today (Late April 2019)
Compiling from (the right) source
Hopefully, this will get fixed, but installing from Homebrew and even after code signing it (more on that later) resulted in the error:
When trying to actually run within gdb, lot’s of Googling and much head scratching it appears, that the version of source that Homebrew is using has a couple of bugs in it. This isn’t Homebrew fault, rather an issue with upstream.
So compiling from source using the latest 8.2.1 which at the time was the most recent release was my next step, and like Homebrew it also failed (which makes sense as that’s the same source they would be using).
Next up was to go bleeding edge… yep no dice, that didn’t even compile
So after looking through issues, it appears the issue was patched a little bit after 8.2.1 was released which was December 2018. Looking to early 2019 there was a series of 8.2.50 commits, before moving to 8.3 so in the end, I took a punt on the Feb 26th Snapshot the actual snapshot I used was.
From there it was pretty simple:
Important (I think) I have GCC 8 setup by default via Homebrew
Several folks have mentioned in various threads about compiler failures. As I already use GCC I have no idea if those are historic issues or not.
By default we now end up with gdb installed into:
So that’s the end of the story right….
Creating a code signing certificate
Regardless of how you get a binary, before you can get it working you need to get a certificate and associate it with the binary to allow code signing otherwise you get
Creating a new certificate isn’t particularly complicated:
With a certificate created, restart the machine. Yes there are other ways to do this, but trust me its just easier to restart and be sure everything is working.
Right with a certificate we need to apply it to the binary, first of create an entitlements file, this is an XML file that shows associated permissions you want to grant the binary.
With the file saved (in my case as gdb.xml) then the final setup is:
Ok surprisingly at this stage it’s working and you can start using gdb on MacOS congrats.
Few Gotchas
Gdb For Mac
Ok assuming you found this after some Googling, you might reach the end of the above steps and run gdb think everything is going fine and it hangs with a message something like:
Gdb Install Windows
If this is you, then edit your ~/.gdbinit file to not include the line:
Chances are like me you added this early on in your trying to get things working, as it was announced in several places as a potential fix. I’m not actually sure why it doesn’t work and it may work for you. I’m slightly suspicious that it might be due to using ZSH but removing the line solved the issue for me, so I dug no further.
While trying to get things working at some point you might have runin which case I would recommendas there is no reason to enable it.
Couple of other things to consider, if you haven’t already make sure you uninstalled gdb via Homebrew if you installed that way, or it’s likely to relink at some point causing chaos.
How To Install Gdb
Also, that certificate you generated, will expire…
So you might want to make a note on how you made it and put in your diary to renew or it’s going to confuse the hell out of you next year.
The last gotcha is more of a comment and specific to Rust, when debugging something built from cargo it leaves an almighty mess, with lots of references to missing files and being unable to read symbols. This doesn’t seem to affect anything other than adding to any warnings your code might actually have. Using rustc -g didn’t come with such gumph but also is way less convenient so for now, I’m just going to live with it.
Osx Gdb
So there we have it, how to install a 30-year-old workhorse tool that has probably been installed on thousands if not millions of machines. Yet due to a combination of MacOS tightened security, some weird rabbit holes caused back with High Sierra and a couple of bugs in the 8.2.1 source has caused more than a little headache for me.