Using CUDA with Visual Studio 2017

I am trying to install CUDA, but I get a message that says "There is no supported version of the visual studio." I think this is due to the fact that I use Visual Studio 2017 (Community), and CUDA currently only supports Visual Studio 2015. Unfortunately, Microsoft will not allow downloading older versions of Visual Studio without paying a monthly fee.

Is there a way around the compatibility issue with VS 2017, or can't I use CUDA?

+18
parallel-processing visual-studio gpu cuda
source share
8 answers
  1. If you want to install CUDA 8.0 with Visual Studio 2017 you need to install additional components for Visual Studio 2017.

    Click on the Start menu and enter the Visual Studio installer. Open the Visual Studio Installer

    Open the tab " Individual components " and select VC++ 2015.3 v140 toolset
    under Compilers, build tools and runtimes .

install additional components for Visual Studio 2017

  1. You also need to install the .NET Framework 3.5 if you do not have it installed.
    The Nvda.Build.CudaTasks.v8.0.dll depends on the MS.NET Framework 3.5 .

Open the classic control panel, go to Programs and features
and click Turn Windows features on or off . Check the .NET Framework 3.5 and click OK.

enter image description here

  1. Download the full CUDA toolkit distribution and unzip it somewhere on your disk.
  2. If you did not have the CUDA toolkit installed, do it now. If you only have Visual Studio 2017 installed, clear the " Visual Studio integration .


Now you want to receive the error message "No supported version of the visual studio was found" .

But to successfully build Cuda toolkit projects in Visual Studio 2017 you also need to follow steps 5 and 6.

  1. Go to CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions
    folder in the unpacked distribution, copy all the files and paste them into
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\BuildCustomizations:

msbuild

  1. In the last step, you will need to edit your Cuda projects to recognize NVidia build tasks from Visual Studio 2017 . Open the .vcxproj file in a text editor and find all the occurrences of CUDA 8.0.props . Replace the macro at the beginning of the line with $(VCTargetsPath14) so that the XML fragment looks like this:

<ImportGroup Label="ExtensionSettings"> <Import Project="$(VCTargetsPath14)\BuildCustomizations\CUDA 8.0.props"/></ImportGroup>

Remember to edit the path of custom targets at the end of the file:

<ImportGroup Label="ExtensionTargets"> <Import Project="$(VCTargetsPath14)\BuildCustomizations\CUDA 8.0.targets"/></ImportGroup>



Make sure to double check your path configuration!
If you use nvcc from the command line, you can not call cl.exe from the Visual Studio folder!

another cl.exe might be in path

Now you can create your Cuda project from Visual Studio 2017.

Parts of this decision are taken from the blog of Oleg Tarasov .

+37
source share

Currently, Microsoft is still making the VS2015 Update 2 community available. You should join the dev essentials program, but it seems to be free.

I recently managed to download the installer from here .

Update: CUDA 9 RC was released yesterday at developer.nvidia.com to registered developers, and it supports VS 2017.

+4
source share

Thank you all for your help. I just wanted to complement this post with the last pieces of the puzzle. CUDA v9.0 RC is looking for VS2017 to identify it as 1910, but the latest update actually identifies it as 1911. To fix open ... / CUDA / v 9.0 / include / crt / host_config.h and change this line:
#if _MSC_VER < 1600 || _MSC_VER > 1910
to that:
#if _MSC_VER < 1600 || _MSC_VER > 1911

You may also need to add the following to your CMakeLists:
list(APPEND CUDA_NVCC_FLAGS --cl-version=2017)

+4
source share

For people seeing this last.

First try installing CUDA 10 (CUDA Toolkit 10.0).

If it still does not work without any mods, make sure that you have as many VC ++ toolkits as you see in the list. Watch this video , stop at 8:41 and compare the listings.

If for some reason you need to use CUDA 9.0 - 9.2, you will need to make a few jumps:

  • For cmd builds set vcvars_ver = 14.11 - see this answer
  • For IDE assemblies, set the Platform Toolset (in the project properties - General) to
    • Visual Studio 2017 (v141)) or
    • Visual Studio 2015 (v140))

If you have a very customized cmd-based build, #if _MSC_VER (in .../CUDA/.../include/crt/host_config.h ) and remove the trailing || _MSC_VER >... || _MSC_VER >... || _MSC_VER >... || _MSC_VER >...

+3
source share

To make the nvcc Cuda compiler nvcc in the Windows shell, you need to do the following

  1. install the appropriate version of the toolbox from a separate component for VS 2017 - VC++ 2017 version 15.4 v.14.11 toolset

  2. Run the following "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.11 in the Windows shell

  3. You can compile nvcc code without errors from windows shell

+1
source share

I ran into the same issue using CUDA 9.1 and VS2017 Enterprise.

After changing the VC ++ compiler to v140 (instead of 141) everything works fine.

There were already flags

 #if _MSC_VER < 1600 || _MSC_VER > 1911 

But this will not stop showing the error.

I don’t know why, but trying to run it on VS2015 leads to errors that v141 is not installed ... therefore, due to some kind of perverse logic, I tried not to use v141, where it was installed ... and it worked! !

Leaving this here as it might help someone else in the same situation. (although I really do not understand why, how, when, who or what of this decision.

0
source share

The latest update (correct as of 12/12/2018), the latest version of Cuda is 9.2, and the latest version of Visual Studio 2017.7 DO NOT work together. The instructions in the solution above do not work. Here is what worked for me:

  1. Uninstall Visual Studio.
  2. Remove Visual Studio Installer
  3. Download Visual Studio 2017.6 (note that Microsoft is known to change links and editions without prior notice) https://docs.microsoft.com/en-us/visualstudio/productinfo/install-an-earlier-release-of- vs2017
  4. Run installer
  5. Go to individual components. Click on the Windows 10 SDK 10.0.15063, enter a description of the image here

  6. Download the cuda Toolkit from the official website: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

  7. You may need to download the patch.
0
source share

I wanted to edit my CUDA programs using a text editor (i.e. Sublime) and compile them from the command line, but I ran into an nvcc compiler error. I installed Visual Studio 2017 with Windows 10, but after compiling it, he said that "only versions VS 2012, 13, 15, and 17 are allowed." So, I decided to add the VC ++ 2015 toolkit from the VS 2017 installer installation package (see Image of the top post). Instead, I did not go through the whole process, I just copied the path of my cl.exe file from the newly created VS 14.0 folder to the environment variable. .Exe can be found here:

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin 

Hope this helps!

0
source share

All Articles