Using CUDA with Visual Studio 2017

后端 未结 8 1672
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 21:53

I\'m trying to install CUDA, but I get a message saying \"No supported version of visual studio was found\". I think that this is because I am using Visual Studio 2017 (Comm

相关标签:
8条回答
  • 2020-11-28 22:33

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

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

    0 讨论(0)
  • 2020-11-28 22:33

    I wanted to edit my CUDA programs using a text editor (i.e. Sublime) and compile them from the command prompt but I ran into an nvcc compiler error. I installed Visual Studio 2017 with Windows 10 OS but after compiling, it said "only version of VS 2012, 13, 15 and 17 are allowed." So what I did was to intall VC++ 2015 toolkit from the installation package of the VS 2017 installer (refer to the image of the top post). I didnt go through his entire process instead, I only copied the path of my cl.exe file from the newly created VS 14.0 folder to the environment variable. The .exe can be found here:

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

    Hope this helps!

    0 讨论(0)
  • 2020-11-28 22:35
    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 type Visual Studio Installer. Open Visual Studio Installer

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

    1. You also need to install .NET Framework 3.5 if you didn't have it installed.
      Nvda.Build.CudaTasks.v8.0.dll assembly dependents on MS .NET Framework 3.5.

    Open Classical Control Panel, go to Programs and features
    and press Turn Windows features on or off. Check .NET Framework 3.5 and press OK.

    1. Download full CUDA toolkit distribution and extract it somewhere on your disk.
    2. If you didn't have CUDA toolkit installed, do it now. If you have only Visual Studio 2017 installed, unselect Visual Studio integration checkbox.


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

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

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

    1. In the last step, you will need to edit your Cuda projects to recognize NVidia's build tasks from Visual Studio 2017. Open your .vcxproj file in a text editor and find all occurrences of CUDA 8.0.props. Replace the macro at the beginning of the string with $(VCTargetsPath14) so that XML snippet would look as follows:

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

    Don't forget to edit the custom targets path 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 conifuration!
    If you use nvcc from command prompt you might not be calling cl.exe from Visual Studio folder!



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

    Parts of this solution are from Oleg Tarasov blog.

    0 讨论(0)
  • 2020-11-28 22:37

    In order to get working Cuda compiler nvcc in windows shell you need to do following

    1. install proper toolset version from individual component for VS 2017 - VC++ 2017 version 15.4 v.14.11 toolset

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

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

    0 讨论(0)
  • 2020-11-28 22:43

    For people seeing this latter.

    First, try to just install CUDA 10 (CUDA Toolkit 10.0).

    If it still doesn't work without any mods make sure that you have as many VC++ toolsets as you see on the list. Check out this video, stop at 8:41 and compare the lists.

    If for some reason you have to use CUDA 9.0 - 9.2 you will need to jump some hoops:

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

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

    0 讨论(0)
  • 2020-11-28 22:47

    Latest update (correct as of 06/12/2018) latest Cuda version is 9.2 and latest Visual Studio version is 2017.7 do NOT work together. The instructions provided in solution above don't work. Here is what worked for me:

    1. Uninstall Visual Studio.
    2. Uninstall Visual Studio Installer
    3. Download Visual Studio 2017.6 (note that Microsoft is known to change links and revisions without notice) https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017
    4. Launch installer
    5. Go to Individual Components. Click on Windows 10 SDK 10.0.15063 enter image description here

    6. Download 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 patch.
    0 讨论(0)
提交回复
热议问题