cuda-samples icon indicating copy to clipboard operation
cuda-samples copied to clipboard

Can't load sample projects after local installation

Open jperna7254 opened this issue 2 years ago • 3 comments

I followed the procedure for installation of the CUDA Toolkit found here https://docs.nvidia.com/cuda/cuda-quick-start-guide/index.html#local-installer After cloning this repo and attempting to load the projects I got the following error regarding importing the projects.

C:\Users\jerem\source\repos\cuda-samples\Samples\0_Introduction\clock_nvrtc\clock_nvrtc_vs2022.vcxproj : error  : The imported project "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.1.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.1.props" is correct, and that the file exists on disk.  C:\Users\jerem\source\repos\cuda-samples\Samples\0_Introduction\clock_nvrtc\clock_nvrtc_vs2022.vcxproj

This error popped up for all the projects and the reason was the CUDA 12.1.props and CUDA 12.1.targets files were not where my VCTargetsPath was pointing. My CUDA props file was located here

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\extras\visual_studio_integration\MSBuildExtensions\CUDA 12.1.props

But the VCTargetsPath was pointing here

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations

So, it seems the default location for the local installation of the toolkit doesn't match where Visual Studio is expecting to find the visual c++ target files.

jperna7254 avatar Jun 14 '23 03:06 jperna7254

This sucks, what's the solution? I'm not gonna downgrade, these nvidia/MS dudes just gotta get their shit together.

eabase avatar Feb 27 '24 01:02 eabase

@jperna7254 @eabase in case you didn't find the fix, here is how I fixed the issue to run the samples.

In my case the error was "The imported project "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.4.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 12.4.props" is correct, and that the file exists on disk."

Step 1. I checked my .props and .targets version on my system, and I had 12.3 and 12.5 only. (so check what you have on your system, image below for location and files as on my system)

image

Step 2. Now go to your local repository with cuda samples and edit the .vcxproj file associated with your visual studio version. In my case this is *vs2022.vcxproj. We edit this, since .vcxproj is loosely the makefile equivalent for windows visual studio. Now change .props and .targets versions in the .vcxproj file to be the same as the ones in step 1 above. In my case I changed 12.4 to 12.5, which was the latest I had (see image below).

image

iamparik avatar May 29 '24 18:05 iamparik