Deploy CUDA on Windows x64 (MSYS2)

CUDA
MS Windows
howto
A short recipe for setting up a command line CUDA environment in Windows.
Author

Dennis Chua

Published

October 22, 2023

While not difficult to dive into, it takes a few steps to get up and running on NVIDIA’s high performance toolkit CUDA. This section documents my set up, and the subsequent updates I’ve made as I go further into CUDA programming


Required Software

JRE is for the NVIDIA Visual Profiler graphical user interface.

Verifying CUDA Installation

Having a map on hand makes a big difference when embarking on a new journey. To get a proper CUDA system set up in Windows x64, the CUDA Installation Guide is a must have reference.

If you’re like me, you’re aiming to develop in a UNIX-like shell environment, such as MSYS2. Visual Studio comes with a Developer Command Prompt, complete with environment variables set for its development tool chain (cl, cmake, msbuild, etc.). After installing CUDA and the JRE, the VS command prompt should also have the appropriate environment settings for CUDA development as well.

How then do we port the shell variables we need from the VS command prompt to MSYS2? Fortunately, antek tech has written a blog explaining the necessary steps. Afterwards it’s a simple matter of confirming that we have our toolchain set up.

$ nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Nov_22_10:30:42_Pacific_Standard_Time_2023
Cuda compilation tools, release 12.3, V12.3.107
Build cuda_12.3.r12.3/compiler.33567101_0
$ nvvp

NVIDIA Visual Profiler
$ msbuild.exe

MSBuild version 17.6.3+07e294721 for .NET Framework
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not
contain a project or solution file.

Without any input files we get an expected error.

$ cl

Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32532 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.
$ cmake

Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.