I contacted Wolfram Support and they suggested the following
[8]:= CUDACCompilers[]
Out[8]= {}
This empty list is a bug in Mathematica 11.2, but we can use CCompilers[]
In[9]:= CCompilers[]
Out[9]= {{"Name" -> "Visual Studio",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual \
Studio\\2017\\Community",
"CompilerName" -> Automatic}, {"Name" -> "Visual Studio",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\",
"CompilerName" -> Automatic}, {"Name" -> "NVIDIA CUDA Compiler",
"Compiler" -> NVCCCompiler,
"CompilerInstallation" ->
"C:\\Users\\bertr\\AppData\\Roaming\\Mathematica\\Paclets\\\
Repository\\CUDAResources-Win64-11.2.22\\CUDAToolkit\\bin\\",
"CompilerName" -> Automatic}}
And then we can select the compiler we want:
In[10]:= CCompilers[][[2, 3, 2]]
Out[10]= "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
And then set it in the Options of CUDAFunctionLoad
In[11]:= SetOptions[CUDAFunctionLoad,
"XCompilerInstallation" -> CCompilers[][[2, 3, 2]]]
Out[11]= {"CleanIntermediate" -> Automatic, "CompileOptions" -> {},
"CompilerInstallation" -> Automatic, "CreateCUBIN" -> True,
"CreatePTX" -> False, "CUDAArchitecture" -> Automatic,
"Debug" -> False, "Defines" -> {}, "Device" -> Automatic,
"IncludeDirectories" -> {}, "LibraryType" -> "Dynamic",
"ShellCommandFunction" -> None, "ShellOutputFunction" -> None,
"SystemDefines" -> Automatic,
"SystemIncludeDirectories" -> Automatic,
"TargetDirectory" ->
"C:\\Users\\bertr\\AppData\\Roaming\\Mathematica\\ApplicationData\\\
CUDALink\\BuildFolder\\dell7720win10-34008",
"TargetPrecision" -> Automatic,
"TransferProtocolLibrary" -> Automatic, "UnmangleCode" -> True,
"WorkingDirectory" -> Automatic,
"XCompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"}
This seems a nice solution, but again a bug in Mathematica 11.2, this option is not used correctly.
What does work is this:
In[62]:= colorNegate = CUDAFunctionLoad[kernel, "cudaColorNegate",
{{_Integer, _, "InputOutput"},
{_Integer, _, "Input"}, _Integer}, {16, 16},
"ShellOutputFunction" -> Print,
"XCompilerInstallation" -> CCompilers[][[2, 3, 2]]]
During evaluation of In[62]:=
C:\Users\bertr\AppData\Roaming\Mathematica\ApplicationData\CUDALink\BuildFolder\dell7720win10-34008\Working-dell7720win10-34008-34420-5>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
CUDAFunction-9314.cu
Out[62]= CUDAFunction["<>", "cudaColorNegate", {{_Integer, _,
"InputOutput"}, {_Integer, _, "Input"}, "Integer64"}]
So let's hope the suggested solution will work in the next release of Mathematica !