Message Boards Message Boards

CreateLibrary example in CUDALink tutorial: macbook working version anyone?

Posted 10 years ago

I am attempting to make the CreateLibrary example in the documentation (CUDALink/tutorial/Setup#639972394) work on my Macbook pro.

This is the cut and paste from the tutorial, I am trying to adapt the example to my Macbook (i.e., with different options)

demoFile = 
  FileNameJoin[{$CUDALinkPath, "SupportFiles", "cudaDLL.cu"}];
CreateLibrary[{demoFile}, "demo", "Compiler" -> NVCCCompiler, 
 "CompilerInstallation" -> "C:\\CUDA"

]

Does anyone with a MAC have a working example of this? (graphics card: NVIDIA GeForce GT 750M 2048 MB)

I've tried the vanilla:

CreateLibrary[{demoFile}, "demo"]

and I get errors that appear the the compiler cannot find header files, e.g.,

  Compile error: \"/Users/ccarter/Library/Mathematica/Paclets/Repository/CUDAResources-\
    OSX-10.0.0.1/CUDALink/SupportFiles/cudaDLL.cu:5:1: error: unknown \
    type name '__global _ 

Here is (I believe) the relevant compiler information on my system:

 CCompilers[]
    (*
    {{"Name" -> "Clang", 
      "Compiler" -> CCompilerDriver`ClangCompiler`ClangCompiler, 
      "CompilerInstallation" -> "/usr/bin", 
      "CompilerName" -> Automatic}, {"Name" -> "GCC", 
      "Compiler" -> CCompilerDriver`GCCCompiler`GCCCompiler, 
      "CompilerInstallation" -> "/usr/bin", 
      "CompilerName" -> Automatic}, {"Name" -> "NVIDIA CUDA Compiler", 
      "Compiler" -> NVCCCompiler, 
      "CompilerInstallation" -> 
       "/Users/ccarter/Library/Mathematica/Paclets/Repository/\
    CUDAResources-OSX-10.0.0.1/CUDAToolkit/bin/", 
      "CompilerName" -> Automatic}}
*)

CUDADriverVersion[]
(*"6.5.25"*)

CUDACCompilers[]
(*
{"Name" -> "Clang", 
  "Compiler" -> CCompilerDriver`ClangCompiler`ClangCompiler, 
  "CompilerInstallation" -> "/usr/bin", "CompilerName" -> Automatic, 
  "Name" -> "GCC", 
  "Compiler" -> CCompilerDriver`GCCCompiler`GCCCompiler, 
  "CompilerInstallation" -> "/usr/bin", "CompilerName" -> Automatic}}
*)

GPUTools`Internal`$NVIDIADriverLibraryPath
(*"/Library/Frameworks/CUDA.framework/Versions/Current/CUDA"*)

GPUTools`Internal`$CUDALinkSystemLibaries
(*{"/usr/local/cuda/lib/libcuda.dylib", \
"/Users/ccarter/Library/Mathematica/Paclets/Repository/CUDAResources-\
OSX-10.0.0.1/CUDAToolkit/lib/libcudart.6.0.dylib", \
"/Users/ccarter/Library/Mathematica/Paclets/Repository/CUDAResources-\
OSX-10.0.0.1/CUDAToolkit/lib/libcufft.6.0.dylib", \
"/Users/ccarter/Library/Mathematica/Paclets/Repository/CUDAResources-\
OSX-10.0.0.1/CUDAToolkit/lib/libcublas.6.0.dylib", \
"/Users/ccarter/Library/Mathematica/Paclets/Repository/CUDAResources-\
OSX-10.0.0.1/CUDAToolkit/lib/libcurand.6.0.dylib"}*)
POSTED BY: W. Craig Carter
5 Replies

It seems CreateLibrary in V10 is using a compiler option switch not supported by nvcc. Try the following override, it does at least compile on my machine

 CreateLibrary[{demoFile}, "demo", "Compiler" -> NVCCCompiler, "SystemLibraries" -> ""]
POSTED BY: Ilian Gachevski

Bingo! That did it. Thanks Ilian, I don't think I could have found that on my own. Craig

POSTED BY: W. Craig Carter

Thanks George and Bruce, I am able to download and compile the examples from NVIDIA: http://docs.nvidia.com/cuda/cuda-samples/#samples-reference; so I know I have a working version of a compiler.

Bruce, double thanks for the effort of putting this in front of the systems wizards.

The performance of these cuda examples on my mac impresses me. Getting CUDALink to work is my recreational project during the semester break.

I tried this today. I did a CUDAResourcesUninstall[] and CUDAResourcesInstall[]. I did a fresh download of the Mac CUDA download from here: https://developer.nvidia.com/cuda-downloads,

I've tried the following:

CreateLibrary[{demoFile}, "demo", "Compiler" -> "nvcc", 
 "CompilerInstallation" -> "/Developer/NVIDIA/CUDA-6.5/bin"]

This fails with: CreateLibrary::badcomp: "Compiler specification "Compiler" -> nvcc does not specify a compiler driver listed by CCompilers[Full]... which make sense, because that compiler does not show up when I try CCompilers[Full]

This

CreateLibrary[{demoFile}, "demo", "Compiler" -> NVCCCompiler, 
 "CompilerInstallation" -> "/Developer/NVIDIA/CUDA-6.5/bin"]

simply returns $Failed

I am a newbie when it comes to using Links in Mathematica.

POSTED BY: W. Craig Carter

No expert, but there is a new CUDA version (6.5.33) that showed up a couple days ago. That may help.

Also, I'm not sure that the current Xcode has gcc at all. (I see a reverence to gcc in the detritus you posted.)

Learning how to use CUDALink is on my list of things to do for 2015 ;-).

There are reports that older versions of clang or MacOS work better with CUDALink.

Are libraries on Windows and MacOS similar enough to make that analogy?

(I am trying to provoke systems wizzes into making suggestions.)

POSTED BY: Bruce Miller
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