Message Boards Message Boards

Select CUDA C compiler in Mathematica 11.2 with CUDA paclet 11.2 ?

Posted 7 years ago

Dear,

I am using Mathematica 11.2 with the CUDA paclet 11.2.22 on Windows 10 64-bit. I have Microsoft Visual Studio 2015 Community. Although CUDACCompliers[] gives an empty list, (with only VS 2015 installed) CUDAFunctionLoad works fine in Mathematica.

But I have just installed Visual Studio 2017 Community to program in C++ with the just released nVIDIA CUDA Toolkit 9.0. The CUDA paclet 11.2 is still based on nVIDIA CUDA Toolkit 8.0 which does not support VS 2017. CUDACCompliers[] is still an empty list, although VS 2015 and VS 2017 are both installed. But CUDAFunctionLoad selects VS 2017 to compile, which fails for the reason I just mentioned.

How can I overrule Mathematica's choice for VS 2017? It should select VS 2015 for now...

Kind regards,

Bert

POSTED BY: Bert Aerts
2 Replies
Posted 6 years ago

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 !

POSTED BY: Bert Aerts
Anonymous User
Anonymous User
Posted 7 years ago

I'm not one to answer, but check the directory (in your Home directory) that Mathematica uses to store your prefereces and also .m in Mathematica's program directory. (.m is the "simple text" version of .nb, you can say)

The choice very well may be in one of those .m, and if it is: you can edit it.

An alternate strategy (other than waiting for WR to fix it, which i assume you already requested by support email), would be to trick it: in your program folders or "program links" make 2015 to run where 2017 is found, tricking it to run 2015 instead of 2017. You'd then need a different "program link" if you were starting 2017 for some other purpose.

POSTED BY: Anonymous User
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract