Skip to content

Using cuda package on Windows

Michał Wawrzyniec Urbańczyk edited this page Sep 27, 2015 · 7 revisions

The cuda package works on Windows and is actively maintained. If you build your applications for 64-bit architecture, you'll need to update your ld.exe as described below. If you encounter any other issues, please report them.

The ld.exe issue (affects 64-bit builds only)

If installation of cuda package fails during the configure phase saying that old (< 2.25.1) version of ld.exe was detected and needs to be replaced, please follow instructions below.

The ld.exe distributed with 64-bit GHC will create broken programs that will crash in the runtime as soon as the first call to CUDA is made. This is because it cannot properly handle MS-generated import libraries (that CUDA toolkit uses).

The problem can be relatively easily solved by replacing the linker binary with the patched one. The binutils release from MSys2 that contains backported fix for the described issue is available here: http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-binutils-2.25.1-1-any.pkg.tar.xz

For convienience I extracted the ld.exe binary from the package and uploaded it here: https://github.com/mwu-tow/cuda/raw/fixed-ld/ld.exe

The binary that needs to be replaced is located in the GHC_PATH\mingw\x86_64-w64-mingw32\bin\ directory. It is enough to download the file from link above and use it to overwrite your ld.exe.

There is one more copy of ld.exe in GHC_PATH\mingw\bin\ — it can be replaced as well, though it does not seem to be used.

Please note that having another MinGW installation in PATH before the one shipped with GHC may break things, particularly if you mix 32/64-bit distributions of MinGW and GHC.

For the full discussion about the bug see:

As of writing this article (Sep 2015) all released GHC 64-bit distributions suffer from this issue (including 7.8.4 and 7.10.2). It is expected that any newer release (e.g. 7.10.3 and 8.0) will have this fixed.

The 32-bit GHC distributions work with CUDA correctly without additional workarounds.

Clone this wiki locally