Can't set up the environment for CUDA compilation - visual-studio

I'm trying to build a project which requires CUDA computing, but I keep encountering an error every time I reach CUDA compilation stage.
The error goes as follows:
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
It might be caused by the fact that the environment has already been set up before the nvcc build started since I'm using Visual Studio x64 Native Tools command prompt. When I launch vcvars64.bat from Visual Studio command prompt it throws an error:
%PATH%";C:\Program Files\CMake\bin;C:\Program Files\Git\cmd;C:\opencv\x64\vc15\bin;;C:\Users\grayf\AppData\Local\Microsoft\WindowsApps;C:\Users\grayf\AppData\Local\Programs\Microsoft VS Code\bin;"=="" was unexpected at this time.
When vcvars64.bat is launched from Windows command prompt the error goes away. Seems like nvcc launches vcvars64.bat the second time, but it encounters the error, so it's unable to continue the compliation.
But I can't find a workaround because without setting up the environment by launching vcvars64.bat I'm unable to compile anything at all including a simple test C program and it doesn't even reach the nvcc compilation stage. Anyone had the same issue? I'll be glad to see your answers.

The issue was with my PATH variable in system variables. it contained unnecessary "\" symbols at the end of some paths and an entry that looked like "C:\torch\bin;%PATH%" when it should have been just "C:\torch\bin".
The problem is gone now, nvcc sets up the environment successfuly and vcvars64.bat doesn't throw any errors even when launched from VS Command Prompt.

Related

couldn't determine visual studio generator

I am trying to compile rust's azul gui framework sample code on windows 10 and it's running into the following error:
error: failed to run custom build command for `harfbuzz-sys v0.3.0 (https://github.com/maps4print/azul-dependencies?rev=bf2933b9aac43a7003278862772250398e4fa457#bf2933b9)`
Caused by:
process didn't exit successfully: `F:\Code\rust\azul_demo\target\debug\build\harfbuzz-sys-4d7deefbb1bf663c\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG
--- stderr
thread 'main' panicked at '
couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
', C:\Users\Andrew\.cargo\git\checkouts\azul-dependencies-70bb1f94316762f9\bf2933b\cmake-0.1.35\src\lib.rs:687:25
stack backtrace:
0: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.29\src\backtrace\mod.rs:66
...
I installed cmake and visual studio 2019. Also note that I am using clion ide. Cmake version is 3.15.2.
It says I should run the appropriate vcvars script before building this crate, what does it mean exactly?
EDIT ----
Found vcvars.bat in the visual studio installation folder and ran it. It's still getting the same error.
EDIT2 ----
It looks like an incompatibility between the latest version of visualstudio(19) and cmake. Reverting to 2015 is suppose to resolve the issue.
https://github.com/maps4print/azul/issues/203
When you install Visual Studio, the command-line tools are not available from a generic command prompt. Visual Studio should have installed an entry in your start menu to start a properly configured console.
Or if you haven't started your console from this special entry, Visual Studio should also have installed a script called vcvars.bat somewhere in its install folder. You need to run that script before you can access the command-line tools.

Can't find VisualStudio linker LINK.EXE

I'm following the openCl documentation provided by Altera to setup an FPGA board and run an example on it. So far I have installed the SDK and followed the instructions but when I get to the step where I have to compile the kernel, I get the following error:
Error: aoc: Can't find VisualStudio linker LINK.EXE.
Either use Visual Studio x64 Command Prompt or run %ALTERAOCLSDKROOT%\init_opencl.bat to setup your environment.
So I tried running the init_opencl.bat script but I get the following message:
AOCL_BOARD_PACKAGE_ROOT path is not set in environment
Setting to default s5_ref board.
If you want to target another board, do
set AOCL_BOARD_PACKAGE_ROOT=board_pkg_dir and re-run this script
VisualStudio's link.exe is not on the path. Guessing its location.
Cannot find VisualStudio installation by looking at the environment.
If VisualStudio is installed, use VisualStudio Command Prompt to set all
required environment variables.
Here is a link to the documentation I am trying to follow:
https://documentation.altera.com/#/00016207-AA$NT00067143
I also tried adding link.exe to the environment variables path but that had no luck. (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe).

CMake and Visual Studio with not default installation folder

I am trying to build something using CMake and VS 2012. The problem is I have my VS installation on D:\Pliki programów (x86)\Microsoft Visual Studio 11.0. I have no free space on my C drive.
CMake have problem with finding my VS. I tried to specify VS compiler cl.exe but it was asking for dll in the same folder anyway. I also tried to use specified toolchaing with vcvarsall.bat. But I am not sure if I am doing those things right.
I guess that I need to add VS location to CMake, but how? I tried setting PATH but it did not work.
And searching about that problem is difficult, all search engines think that I want to change installation path for my program that I want to build.
UPDATE
I've added variable_watch(CMAKE_MAKE_PROGRAM).
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using UNKNOWN_READ_ACCESS with
value .
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using MODIFIED_ACCESS with value
C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
In output file:
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
Is CMake looking for libs in VS 11 installation folder? The thing is that VS installer put libs in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64.
For cases like this (and similar), I keep a VCEnvCmd.bat in my source trees:
call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 & %*
Executing that .bat without parameters will find and run vcvarsall.bat, setting up the environment for the amd64 target in the current shell (which you could change or parameterize according to your needs, like the version number embedded in that environment variable).
The nice trick is, for those Nightly / Continuous builds, you can use the .bat as a "prefix" for setting up the environment, e.g. in the task manager:
VCEnvCmd.bat ctest -S CTestScript.cmake,Nightly
The advantage is that you use what MSVC already gives you (the VS...COMNTOOLS variable), without having to clutter your environment further with persistent changes to PATH etc.

Setting Up .NET Build Environment with setenv - Two Warnings - Could not find vsvars32.bat Visual C++ Does not appear to be installed

I'm trying to compile some netmf firmware using MSBUILD with Yagarto. I'm doing it on a machine with VS2012 and all the right pre-requisites installed. From a command prompt as administrator, I go to the NetMF Porting Kit folder, where all the source code lives, I call setenv_gcc.cmd 4.6.0 c:\yagarto46
Doing so yields two warnings:
WARNING: Count not find vsvars32.bat
WARNING: VISUAL C++ DOES NOT APPEAR TO BE
INSTALLED ON THIS MACHINE.
When I try the above command from VS2012 Developer Command Prompt as Administrator I get the following ERROR
ERROR: Cannot determine the location of the VS Common Tools folder.
I've done the path modifications in Environment System Variables with no luck.
Thanks!
VS2010 command prompt gives error : Cannot determine the location of the VS Common Tools folder
I modified the vsvars32.bat file in the vs11 and vs10 folders accordingly and the error went away... Now onto eliminating my build errors....

LoadLibrary fails to load dll with error code 126, when building in Visual Studio

This project consists of a single .cpp file which calls LoadLibrary() to load a dll-file.
What happens is that if I run the following through the Microsoft Visual Studio 2012 Command Prompt:
cl /nologo Test.cpp
Everything works fine.
On the other hand, if I start up a simple Visual C++ project, add the file and compile it through there, the LoadLibrary() call fails with code 126: The specified module could not be found.
The .exe I build from the command line is more than twice the size of the one built in Visual Studio. So I guess there's some static linking going on.
The .dll-file is fine, and it's in the same directory as the .exe-file.
I figured it out.
By default the cl command uses the multibyte character set. While new projects set up in Visual Studio are configured for unicode.
if Loadlibrary function fails with error 126
that clearly shows that it was not able to find the library.
so you can check this function by appling full path in Loadlibrary's argument.
if it works then set that path in PATH variable of system environment variable.
because Loadlibrary api first find that full path, if it was not able to find the library at that path then it search it in systems standard PATH.
does your operating system is 64-bit it?
I have encountered this situation on my win7(64-bit), but not in VS,photoshop(64-bit), matlab-2011a(64bit). Prompts are the same: Loadlibrary failed with error 126 ...
As far as I know,“they’re missing a registry entry critical to its functionality. Specifically, whenever an application requests OpenGL access, AMD’s atig6pxx.dll kicks in. It then peeks inside HKLM\SYSTEM\CurrentControlSet\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\0000 and loads the OpenGL component as specified by OpenGLVendorName (64-bit) or OpenGLVendorNameWow (32-bit).”
You can refer to this blog(enter link description here), and it gives the solution。I tried and it worked.or you can refer to this forum(enter link description here)。
I hope it could solve your problem,go luck:)

Resources