Categories: CUDA

Setting up for CUDA Dev Work

I have started exploring parallel programming using CUDA. The latest release as of this writing is 11.8 as detailed at CUDA Toolkit 11.8 New Features Revealed | NVIDIA Technical Blog. I’m using Windows and have Visual Studio 2022 installed. I have 2 CUDA-capable devices: a Surface Book 2 with a GeForce GTX 1060 and an HP Z4 G4 Workstation with a Quadro P1000. The compute capabilities supported by these cards is at CUDA GPUs – Compute Capability.

I had previously installed the 11.1 toolkit on my Surface Book so I started by uninstalling all apps that showed up when searching for “nvidia” under “Installed Apps” except NVIDIA Graphics Driver 461 and NVIDIA Update 38.0.2.0. I then got the new installer from Installation Guide Windows :: CUDA Toolkit Documentation (nvidia.com) and installed every component presented by the installer. Note that older builds can be found at the CUDA Toolkit Archive.

Installed NVIDIA CUDA Components

You can now create a new CUDA project in Visual Studio:

Visual Studio’s Create New Project Dialog

Surface Book 2 CUDA Issues

Creating and running a CUDA 11.8 Runtime project on my Surface Book 2 fails with the error cudaSetDevice failed! Do you have a CUDA-capable GPU installed?addWithCuda failed! A search for using nvidia GPU on surface book 2 leads to suggestions that involve the NVIDIA Control Panel. Unfortunately, it doesn’t start on my laptop. A peek at the event viewer reveals why:

Faulting application name: nvcplui.exe, version: 8.1.940.0, time stamp: 0x61b5030e
Faulting module name: nvcplui.exe, version: 8.1.940.0, time stamp: 0x61b5030e
Exception code: 0xc0000409
Fault offset: 0x00000000002947f5
Faulting process id: 0x0x6340
Faulting application start time: 0x0x1D8D9CC4435E10D
Faulting application path: C:\Program Files\WindowsApps\NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj\nvcplui.exe
Faulting module path: C:\Program Files\WindowsApps\NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj\nvcplui.exe
Report Id: 5500d6c8-eebe-4488-8863-397c3896c777
Faulting package full name: NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj
Faulting package-relative application ID: NVIDIACorp.NVIDIAControlPanel

Opening the dump file in Visual Studio to see what’s going on is not helpful because there are no symbols available for the NVIDIA binaries. The NVIDIA Driver Symbol Server even says that it does not have PDBs (even though that’s for drivers) so this is not an optimistic path. The trimmed callstack of the main thread from the dump is shown below though. The paths to the NVIDIA binaries are C:\Program Files\WindowsApps\NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj\nvcplui.exe and C:\Windows\System32\DriverStore\FileRepository\nvmsoui.inf_amd64_8fd9664c41d93f19\nvgames.dll

>	nvcplui.exe!00007ff756d547f5	Unknown
 	nvcplui.exe!00007ff756d529c7	Unknown
 	nvcplui.exe!00007ff756d09f57	Unknown
 	KERNELBASE.dll!UnhandledExceptionFilter	C
 	[Inline Frame] ntdll.dll!RtlpThreadExceptionFilter	C
...
 	ntdll.dll!RtlRaiseException	C
 	[External Code]	
 	nvgames.dll!00007ffd372ba7d2	Unknown
...
 	nvgames.dll!00007ffd36ffd59f	Unknown
 	combase.dll!???::CreateInstance	C++
...
 	[Inline Frame] combase.dll!CoCreateInstanceEx	C++
 	combase.dll!CoCreateInstance	C++
 	nvcplui.exe!00007ff756afdf63	Unknown
...
 	nvcplui.exe!00007ff756d08f63	Unknown
 	kernel32.dll!BaseThreadInitThunk	C
 	ntdll.dll!RtlUserThreadStart	C

Launching it again errors with a dialog claiming that an NVIDIA graphics card was not detected in my system. Check out the language too…

Sure enough, device manager no long shows the GTX 1060 in the list of display adapters.

Rebooting restores the GTX 1060 but doesn’t address the crash in the NVIDIA Control Panel so I decide to move to my workstation and everything is much smoother there. The new Visual Studio CUDA project runs to completion so I turn my attention back to the CUDA installer to work on resolving the Surface Book 2 issues. The first thing I notice is that the installer is not keyboard accessible, so here’s a detour…

NVIDIA Installer Accessibility Issues

Is the NVIDIA Installer narrator-friendly? Narrator informs me that there are new natural voices available so I install them (Microsoft Aria, Guy, and Jenny).

CUDA 11.6 Driver Components

Looks like narrator works with the installer. However, the installer cannot be used via keyboard alone due to these issues:

  1. You cannot TAB out of the NVIDIA software license agreement.
  2. Narrator doesn’t read the captions below the Express and Custom radio buttons on the Installation Options page.
  3. You cannot TAB into the components tree to select them via keyboard.
  4. Keyboard navigation works after clicking on a component but the focus goes back to the NEXT button after using ALT+TAB to switch to another program then back.
  5. Narrator reads the individual components, e.g. “NSight Systems, Selected” regardless of whether the checkbox is ticked or not. How does one know it’s a checkbox?
  6. The custom installation components columns are not resizable (Component, New Version, and Current Version). For example, what NVIDIA GeForce Experience compo
  7. Why isn’t it resizable?

A general usability issue: why do all the NVIDIA components need to be uninstalled individually instead of having an option to remove everything?

Outstanding Questions

  1. How do we figure out which component installed the NVIDIA Control Panel? One approach is to uninstall the existing components until the control panel binary from the dump file is deleted on disk. Removing NVIDIA NSight Systems 2022.4.2 removed the C:\Program Files\WindowsApps\NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj\ directory. However, installing only this component in 11.6 did not bring back the NVIDIA control panel!
  2. The installer asks for a path to a temp directory to unpack setup file into. Could examining that folder help determine where the control panel is coming from?
  3. Was this installer generated by NSIS?

Resolution

I end up uninstalling all “nvidia” components on the Installed Apps page except NVIDIA Graphics Driver 461.40 then installing all components from CUDA 11.6. This finally has a working control panel!

NVIDIA Control Panel from CUDA 11.6 Installer

Surprisingly, this executable is in C:\Program Files\WindowsApps\NVIDIACorp.NVIDIAControlPanel_8.1.962.0_x64__56jybvy8sckqj, the same directory as 11.8! This must not have been the buggy component! Here is the version info for the 2 NVIDIA binaries in the earlier crash dump (nvgames.dll is now in C:\Windows\System32\DriverStore\FileRepository\nvmsoui.inf_amd64_ed4d74dfae95b5e6):

nvcplui.exe Properties

Visual Studio 2022 does not have the new CUDA project option though. However, changing the paths (in the .vcxproj) for my new project created using the 11.8 tools on my VS 2022 desktop makes the program work. Looks like I need to use 11.7 instead so I uninstall all the “nvidia” components except the NVIDIA Control Panel and the NVIDIA Graphics Driver 511.23 before installing 11.7. Thankfully, 11.7 works just fine!


Categories: CUDA, Graphics

Testing nVidia Cuda Samples

I have been toying around with the idea of doing a fluid dynamics or crystal growth simulation using nVidia CUDA. I decided to try out nVidia’s cuda samples to see what their approach looks like, in particular when rendering using OpenGL. I am using Visual Studio 2022 so I simply cloned the cuda samples repo, opened the fluidsGL_vs2022.sln solution, right click on the fluidsGL project, then selected Build.

Build started...
1>------ Build started: Project: fluidsGL, Configuration: Debug x64 ------
1>D:\dev\...\cuda-samples\Samples\5_Domain_Specific\fluidsGL\fluidsGL_vs2022.vcxproj(37,5): error MSB4019: The imported project "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 11.6.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\\BuildCustomizations\CUDA 11.6.props" is correct, and that the file exists on disk.
1>Done building project "fluidsGL_vs2022.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The prerequisites section does mention that the CUDA Toolkit 11.6 is required, so I close VS and install it. I end up with version 11.7 though:

When reopening the fluidsGL solution, I still get the same error about CUDA 11.6.props not being found. A quick look at the directory this file is expected to be in reveals that this is a simple version mismatch problem – see the hard coded version in the fluidsGL.vcxproj file. Instead of fixing every example .vcxproj file to match CUDA 11.7, we can patch the VS folder by running these commands from an admin command prompt:

cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations"

copy "CUDA 11.7.props" "CUDA 11.6.props"
copy "CUDA 11.7.targets" "CUDA 11.6.targets"

The code now builds in Visual Studio and I can now oooh, aaaah over the demo. Visual Studio does seem a bit sluggish at opening the entire samples solution though… I get this information about my device in the console window after the demo launches:

GPU Device 0: "Pascal" with compute capability 6.1

CUDA device [Quadro P1000] has 5 Multi-Processors
After clicking and dragging mouse around