What do I need to do CUDA development on Windows 10? - visual-studio

I've installed the CUDA 10.2 tools on Windows 10 along with Visual Studio Community Edition. When I run the nvcc compiler on a .cu file from the command line it complains that it cannot find cl.exe, which apparently is a Microsoft compiler. If cl.exe is part of VSCE it didn't get put on the PATH. Maybe there are additional steps that I don't know about
Also, VSCE doesn't know what .cu files are and I can't find any extensions for NVidia or CUDA.
Does VSCE support CUDA development, or do I need the commercial edition or something else to get going with CUDA development on Windows?
Update:
I tried building one of the sample projects (CUDA Samples\v10.2\1_Utilities\deviceQuery) by importing it into VSCE and it fails with this message:
Error MSB4019 The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 10.2.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\\BuildCustomizations\CUDA 10.2.props" is correct, and that the file exists on disk.

The solution is here. The CUDA installation guide fails to mention that you have to copy several files from the CUDA installation to the VSCE installation.

Related

Visual Studio 2022: Cannot open include file: 'ctype.h'

I've got the infamous error message in C++ build: "Cannot open include file: 'ctype.h'". I know a similar question was already asked multiple times, but my case seems different because I am using the latest Visual Studio 2022 and seems to behave differently.
I have a bunch of existing C++ projects, they use plain 32-bit Windows API with DirectX 6, and I used VC++ build tools 2015 and Windows SDK 8.1 to compile it without any issues in previous versions of Visual Studio. Everything was fine in Visual Studio 2019, no special setup was needed, until I uninstalled it and installed Visual Studio 2022.
Now I can open my solutions, it nicely shows they are using C++ build tools 2015, which I installed together with VS2022, and the solutions also shows correctly that they use Windows 8.1 SDK. But Windows 8.1 SDK is not present in VS2022 installation, I installed it separately. I also tried to "repair" VS2022 installation, but that only deleted all my UI preferences, but not fixed anything in build. Also, I tried to reinstall Windows 8.1 SDK, but it said it is already OK.
When looking to Visual Studio, I can't see any place where I can set default include and lib directories, I can only list what is being used right now. VS2022 shows this list:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
C:\Program Files\Windows Kits\10\Include\10.0.10240.0\ucrt
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt
The actual error message I receive is this:
c:\program files (x86)\windows kits\8.1\include\um\winnt.h(31): fatal error C1083: Cannot open include file: 'ctype.h': No such file or directory
So it says that winnt.h from windows kits 8.1 cannot find ctype.h. And yes, there is no ctype.h in that folder or anywhere around, I can see it only in C:\Program Files\Microsoft Visual Studio\2022\Professional\SDK\ScopeCppSDK\vc15\SDK\include\ucrt
which I think is the folder with VC++ 2015 build tools. So this seems correct, but I am wondering why this folder is not a part of default include directories when VC++ 2015 build tools are set in project settings. Because it seems that VS2022 is correctly picking my Windows 8.1 SDK, but not picking correctly the older C++ compiler.
When I try to add the folder where ctype.h resides to include folders, I receive another type of errors saying that other files are incompatible with these include files. Of course, this system of directories needs to be in sync. So please what is the correct way of using this?
Also, I tried to switch the VC++ build tools to 2022 version. Unfortunately, that also does not fix the issue. And Windows 10 SDK is not installed, the software wants to stay compatible with older Windows, so I don't need it.
I found a bug report which is related: https://developercommunity.visualstudio.com/t/windows-81-sdk-1/151682
Although Microsoft staff declined to accept it as a bug, it is happening for me as well. When I install only Windows 8.1 SDK, no project can be compiled with it. I even tried to create a new Windows API project in VS2022, the project was created, but failed to compile with the same error.
So I tried to install Windows 10 SDK (from VS2022 installed, but that is probably not important) and this added some missing files which now help to compile Windows 8.1 SDK projects. Problem seems to be solved, my old C++ code can now be compiled with Windows 8.1 SDK and both C++ build tools 2015 and 2022.

vcvars64.bat file is missing

I installed visual C++ express from http://www.visualstudio.com/en-us/downloads#d-2010-express. I have also installed Microsoft SDKs http://www.microsoft.com/en-us/download/details.aspx?id=8279.
I need the vcvars64.bat for the installation of one of my programs (Gnu Linear Programming Kit or GLPK). Unfortunately, I don't see this file in C:/Program Files (x86)/Visual Studio 10.0/vc. I typed the following command in cmd terminal:
"CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64"
But it does not create the vcvars64.bat file in the intended place.
Can I just download this file from some webpage and put it in C:/Program Files (x86)/Visual Studio 10.0/vc ? Any feedback will be very appreciated.
Thanks,
Nazmul
The file is located in VC/bin/amd64 in the Program Files folder for Visual Studio 2010
Edit: Sorry, I checked with my own 2010 install, which is not an "Express" one. VS2010 Express comes without a 64 bits compiler.
See How to compile a 64-bit application using Visual C++ 2010 Express?

QtQreator 5.2 won't compile any project and gives C1083: Cannot open include file: 'stddef.h': No such file or directory

I installed Qt5.2 msvc2012 version on my system, and after couple of failed tries to compile my projects - which were coded in the mingw version on windows (actually the Android package one) - I tried to create a new gui project and see if that works.
No surprise it didn't work and gave me the error:
F:\ms\Qt5.2.0\5.2.0\msvc2012\include\QtCore\qglobal.h:46: error:
C1083: Cannot open include file: 'stddef.h': No such file or directory
I searched a lot of places but couldn't figure out what was causing this problem. I even uninstalled the mingw version completely (5.2.0-android-x86-win32-offline.exe) still no luck.
I had Visual Studio 2010 and Visual Studio 2013 installed on my system when I went for installing qt5.2, the mingw version worked fine till when I had to switch to msvc for my project. I tried installing 5.2.0-msvc2012-x86-offline.exe and noticed it needs Visual Studio 2012 in order to compile, so I went and installed Visual Studio 2012.
After that I am getting such error plus several ones mentioned here. I even tried installing WDK and WSDK but it's not working. The path I believe is configured correctly and files do exist. This is my include path in environmental variable on windows 7sp1 x86
J:\Program Files\Microsoft Visual Studio 11.0\VC\INCLUDE;J:\Program Files\Microsoft Visual Studio 11.0\VC\ATLMFC\INCLUDE;C:\Program Files\Windows Kits\8.0\include\shared;C:\Program Files\Windows Kits\8.0\include\um;C:\Program Files\Windows Kits\8.0\include\winrt;
What is wrong and how can I solve this problem?

Compile CUDA without Visual Studio - "Cannot find compiler cl.exe in path"

I've just begun a small project in CUDA.
I need to know the following:
Is it possible to compile CUDA code without using/buying Microsoft Visual Studio?
Using Nvcc.exe I get the error "Cannot find compiler cl.exe in path".
I've tried to install a CUDA plugin for NetBeans, but it doesn't work. (with current version of NetBeans)
Platform: Windows 7
Thanks in advance.
Update
As noted in the comments, versions of the SDK after Windows 7's do not include the build tools. If you want to use Microsoft's most recent tools you have to install Visual Studio. Once installed, you can use the tools from the command-line.
At the moment the free versions are the "Community" versions, e.g. Microsoft Visual Studio Community 2015.
You can continue to develop apps for Windows 7 and earlier (and they will run on later versions of Windows) using the old SDK tools as I described before:
Original Answer
If you desperately want to avoid Visual Studio, download and install the Windows SDK. This contains (more or less) the same build tools as Visual Studio.
Then run the Windows SDK Command Prompt (which you'll find on the start menu under Microsoft Windows SDK) to set the path to point to the tools, and you are set.
Or just use Visual C++ Express.
Following the previous comments I've installed Studio Express & VS2010.
This did not solve the "cl.exe not in path" problem.
I solved the problem with the error Cannot find compiler cl.exe in path, by including
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 in PATH,
before installing Windows SDK.
This question also contains valuable information.
For some reason VS2010 & Studio Express failed to set the proper variables in path even after the execution of vsvars32.bat.
Thank you all for your valuable help.
add this options to nvcc
nvcc x.cu <other options> -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"
i use VS2012 and my cl.exe dir is here.
You have to figure out where NVIDIA GPU Computing Toolkit is installed.
In my system it's in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" Then
"Edit Environment Variables" on Windows.
Click on New...
Variable name: NVCC
Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe
Click on OK.
Use windows subsystem for linux and install ubuntu and nvcc along with gcc and g++ using the ubuntu terminal in windows (gui does not works for linux subsystem for windows). Then configure .bashrc using bash and vim/nano with a 'cd' command to your desired location as it is done in usual linux terminal (makes it easy as bash opens in system32 folder everytime). And then you can compile .cu files using nvcc over bash. As nvcc supports gcc and g++ under linux so it solves the problem. No need to sacrifice peace for switching over to linux or dealing with crappy visual studio. It worked for me.

Using boost 1_47 with Visual C++ Express 2010

I have installed and built (successfully as far as I can tell), boost 1_47_0. I am now trying to get the sample program (the regex one) with their install guide to run and it is giving me the following link error:
LNK2019: unresolved external symbol "private: class boost::basic_regex ....
I suspect that the problem is that the libraries were built as vc100 using b2 and the Platform Toolset is Windows7.1SDK. I cannot change the Platform Toolset to v100 or it generates a kernel32.lib missing error. And I cannot seem to figure out how to build boost so that it is sdk7. I am using Visual C++ Express 2010 and have also tried building from the Windows7.1SDK command line prompt.
Any ideas?
I meet the same issue when I install boost with installer from "BoostPro Computing". And I solve it by compiling boost lib from source code.
Here is the steps:
enter Visual Studio 2010 Express Command Prompt
cd to the unzipped boost dir
bootstrap.bat
.\b2
Done.
Here is my environment:
Win7 64bit
Visual Studio 2010 Express
boost 1_52_0
I build boost using a batch file that calls bjam, and I have not had any problems using the regex library in my projects. I am using VS2010 Pro. Here are the lines from my batch file, the extra library locations might not be important to you, I'm just putting them here for completeness:
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
SET ZLIB_SOURCE=%LIBS%\zlib
SET ZLIB_INCLUDE=%LIBS%\zlib
SET BZIP2_SOURCE=%LIBS%\bzip2-1.0.5
SET BZIP2_INCLUDE=%LIBS%\bzip2-1.0.5
SET BZIP2_BINARY=libbz2
SET ZLIB_BINARY=zdll
SET EXPAT_INCLUDE=%LIBS%\Expat\Source\lib
SET EXPAT_LIBPATH=%LIBS%\Expat\Bin
SET EXPAT_BIN=%LIBS%\Expat\Bin
bjam.exe --disable-filesystem2 --build-type=complete --user-config=%UTILS%\user-config.jam
Of course the path to your libraries and your user-config.jam will be different, and the only one line in user-config.jam that is really important is:
using msvc : 10.0 ;
After a successful build you will want to add the path to the stage/lib directory to you additional libraries settings for the project so the linker is satisfied. Also since this is an express build you may have to fiddle with the include path to pick up the platform SDK. I run this batch file from the top level Boost directory.

Resources