[Haskell-cafe] install cuda

150 views
Skip to first unread message

Peter Caspers

unread,
Mar 30, 2013, 3:43:58 PM3/30/13
to haskel...@haskell.org
Hi,

I am trying to install the cuda package on a Windows 7 enviroment.
However I run into an error and can not figure out, what it is.

Can someone help ?

Thanks a lot
Peter

C:\Users\Peter\_dev\haskell>cabal install cuda
Resolving dependencies...
[1 of 1] Compiling Main (
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\Setup.hs,
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1
-11856\cuda-0.5.0.1\dist\setup\Main.o )
Linking
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\dist\setup\setup.exe
...
Configuring cuda-0.5.0.1...
cygwin warning:
MS-DOS style path detected:
C:\Users\Peter\AppData\Roaming\cabal/share/config.site
Preferred POSIX equivalent is:
/cygdrive/c/Users/Peter/AppData/Roaming/cabal/share/config.site
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
checking for gcc... C:\Program Files (x86)\Haskell
Platform\2012.4.0.0\mingw\bin\gcc.exe
checking whether the C compiler works... no
configure: error: in
`/cygdrive/c/Users/Peter/AppData/Local/Temp/cuda-0.5.0.1-11856/cuda-0.5.0.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Error: some packages failed to install:
cuda-0.5.0.1 failed during the configure step. The exception was:
ExitFailure 77

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Henk-Jan van Tuyl

unread,
Mar 30, 2013, 7:56:39 PM3/30/13
to haskel...@haskell.org, Peter Caspers
On Sat, 30 Mar 2013 20:43:58 +0100, Peter Caspers <pcaspe...@gmail.com>
wrote:

> Hi,
>
> I am trying to install the cuda package on a Windows 7 enviroment.
> However I run into an error and can not figure out, what it is.
:
:
> configure: error: C compiler cannot create executables
> See `config.log' for more details
:

The message says it all:
See `config.log' for more details
The config.log file is probably in the directory where cabal-install
unpacks it (%appdata%\cabal\cuda-<revision>); you can also use the
commands:
cabal unpack cuda
cd cuda
cabal install
notepad config.log

I just had the same error message for another package; from the config.log
file it became clear, that the linker could not find the necessary
library. Make sure, that the libraries and header files can be found by
the compiler and linker, by setting the proper environment variables, see
[0]

Regards,
Henk-Jan van Tuyl


[0] http://www.haskell.org/haskellwiki/Windows#Tools_for_compilation


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--

Trevor L. McDonell

unread,
Mar 30, 2013, 10:01:57 PM3/30/13
to Henk-Jan van Tuyl, haskel...@haskell.org
Hi,

CUDA package maintainer here. I don't have access to a Win7 box with compatible GPU, nor a lot of experience writing packages for windows. If you do get it working please send me a pull request on github. I'd be great to have this working for windows as well.

Cheers,
-Trevor

Stephen Tetley

unread,
Mar 31, 2013, 2:54:25 AM3/31/13
to Peter Caspers, haskel...@haskell.org
It looks like you are using Cygwin for a Unix-alike environment. For
building Haskell bindings to C libraries you are better off with MinGW
+ MSYS.

On 30 March 2013 19:43, Peter Caspers <pcaspe...@gmail.com> wrote:

> I am trying to install the cuda package on a Windows 7 enviroment. However I
> run into an error and can not figure out, what it is.
>
> Can someone help ?

Peter Caspers

unread,
Mar 31, 2013, 11:03:22 AM3/31/13
to Henk-Jan van Tuyl, haskel...@haskell.org
Hi,

thank you. I could resolve some of the problems by removing spaces from
the Cuda and Haskell platform installation paths. Now I am left wiht the
following error:

configure:3596: checking for library containing cuDriverGetVersion
configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o
conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads
-I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib conftest.c >&5
C:\Users\Peter\AppData\Local\Temp\ccOsnsjD.o:conftest.c:(.text+0xc):
undefined reference to `cuDriverGetVersion'
collect2: ld returned 1 exit status

In fact the library path
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib is not correct
(there are two subfolders x64 and Win32 containing the lib files) and I
do not see where this path is actually taken from. I defined an
enviroment variable LD_LIBRARY_PATH with the correct paths (separated by
a colon), but it seems to be ignored.

Also copying the lib files to the path I see in the log does not help.

Do you have any hint for me concerning this ?

Peter

Henk-Jan van Tuyl

unread,
Mar 31, 2013, 11:59:11 AM3/31/13
to Peter Caspers, haskel...@haskell.org
On Sun, 31 Mar 2013 17:03:22 +0200, Peter Caspers <pcaspe...@gmail.com>
wrote:

> In fact the library path
> -L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib is not correct
> (there are two subfolders x64 and Win32 containing the lib files) and I
> do not see where this path is actually taken from. I defined an
> enviroment variable LD_LIBRARY_PATH with the correct paths (separated by
> a colon), but it seems to be ignored.
>
> Also copying the lib files to the path I see in the log does not help.
>

The environment variable should probably be LIBRARY_PATH; I use a
semicolon as separator.
See also LD_LIBRARY_PATH vs LIBRARY_PATH[0].

Regards,
Henk-Jan van Tuyl


[0]
http://stackoverflow.com/questions/4250624/ld-library-path-vs-library-path

Geoffrey Mainland

unread,
Mar 31, 2013, 12:23:30 PM3/31/13
to haskel...@haskell.org
Try my fork:

https://github.com/mainland/cuda

In particular, read WINDOWS.md.

Geoff

Peter Caspers

unread,
Mar 31, 2013, 12:55:15 PM3/31/13
to Henk-Jan van Tuyl, main...@apeiron.net, haskel...@haskell.org
>
> The environment variable should probably be LIBRARY_PATH; I use a
> semicolon as separator.
> See also LD_LIBRARY_PATH vs LIBRARY_PATH[0].
>

yes, it's LIBRARY_PATH. The x64 version of cuda.lib is not recognized at
all (same error message as if the file was not existent). The Win32
version "works", but results in

configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o
conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads
-I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib conftest.c
-lcuda >&5
C:\Users\Peter\AppData\Local\Temp\ccOwCQ6n.o:conftest.c:(.text+0xc):
undefined reference to `cuDriverGetVersion'
collect2: ld returned 1 exit status

I ran nm on cuda.lib and got the entry

nvcuda.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
U _IMPORT_DESCRIPTOR_nvcuda
00000000 I _imp__cuDriverGetVersion@4
00000000 T cuDriverGetVersion@4

this looks ok so far. Running nm on the x64 version of the lib file
results in rubbish output (consistent with the observation above).

I understand that LD_LIBRARY_PATH is used to look up to dll when running
the program (is that correct?). However we are not at this point yet,
are we, since the error occurs on the gcc invocation ?

> Try my fork:
>
> https://github.com/mainland/cuda
>
> In particular, read WINDOWS.md.

I also read Geoffreys WINDOWS.md and understood that configuring dll
names are only necessary when using ghci, not for compiled programs
(nothing to do for this case ?) and in particular not for installing the
package ?

Actually the dll is not named nvcuda.dll as indicated in the nm output,
but rather cudart32_41_28.dll I suppose and this file is located in the
bin subfolder. I should set LD_LIBRARY_PATH to the bin folder, yes ?
Should I configure this dll name for package installation already (i.e.
in addition to what is mentioned in WINDOWS.md) ? If yes, how ?

Thank you
Peter

Geoffrey Mainland

unread,
Mar 31, 2013, 2:17:40 PM3/31/13
to Peter Caspers, Henk-Jan van Tuyl, haskel...@haskell.org
You're using a version of GHC that targets 32-bit x86, so the 64-bit
library is not going to do you any good. cuDriverGetVersion@4 is the
stdcall-mangled version of cuDriverGetVersion. The CUDA headers (at
least in the 5.0 toolkit) do not properly declare all CUDA functions as
stdcall under gcc, even though they are. This is why you get an
undefined reference---gcc see cuDriverGetVersion' declared ccall in the
header, so it looks for the wrong symbol. I would guess that the 4.1
toolkit has this same problem the same.

In general, there is no support for using the CUDA SDK with the mingw
tools. I hacked around this enough to get it to work for the driver API,
but you have to use my fork.

> I understand that LD_LIBRARY_PATH is used to look up to dll when
> running the program (is that correct?). However we are not at this
> point yet, are we, since the error occurs on the gcc invocation ?
>
>> Try my fork:
>>
>> https://github.com/mainland/cuda
>>
>> In particular, read WINDOWS.md.
>
> I also read Geoffreys WINDOWS.md and understood that configuring dll
> names are only necessary when using ghci, not for compiled programs
> (nothing to do for this case ?) and in particular not for installing
> the package ?

There's more to it than reading my WINDOWS.md. If you want to build the
cuda package at all, you also need to use my fork.

> Actually the dll is not named nvcuda.dll as indicated in the nm
> output, but rather cudart32_41_28.dll I suppose and this file is
> located in the bin subfolder. I should set LD_LIBRARY_PATH to the bin
> folder, yes ? Should I configure this dll name for package
> installation already (i.e. in addition to what is mentioned in
> WINDOWS.md) ? If yes, how ?

There are two dlls you need. nvcuda.dll corresponds to libcuda on Linux,
and its .lib file on Windows is cuda.lib. cudart32_41_28.dll corresponds
to libcudart on Linux, and its .lib file on Windows is cudart.lib. You
will need them both.

I was able to install the cuda package under 32-bit GHC 7.4.2 using the
5.0 SDK and use it from within ghci. This required using my fork of the
cuda repo and following the instructions in my WINDOWS.md. Make sure
nvcc is in your path (the CUDA installer should have made this so) and
try 'cabal configure'.

LD_LIBRARY_PATH is used on most UNIX flavors. I don't believe it does
anything in Windows. You will instead need to modify your Path
environment variable from the System Settings->Advanced System Settings
control panel.

Geoff

Peter Caspers

unread,
Mar 31, 2013, 2:32:54 PM3/31/13
to Geoffrey Mainland, Henk-Jan van Tuyl, haskel...@haskell.org
yes I more or less saw this in the meantime, too. Actually modifying the
source code on which the error is reported from

configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Haskell CUDA bindings"
| #define PACKAGE_TARNAME "cuda"
...
| #ifdef __cplusplus
| extern "C"
| #endif
| char cuDriverGetVersion ();
| int
| main ()
| {
| return cuDriverGetVersion ();
| ;
| return 0;
| }

to (for example)

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <cuda.h>

int
main( int argc, char** argv)
{
int driverVersion = 0;
cuDriverGetVersion(&driverVersion);
printf("version = %d\n",driverVersion);
return 0;
}

let me compile, link and run without errors. Alright, got it now, I will
try your github. Do you think it works with CUDA 4.1 ? On my laptop this
is the latest version that runs due to the card driver.

Thanks in any case
Peter

Peter Caspers

unread,
Mar 31, 2013, 3:27:59 PM3/31/13
to Geoffrey Mainland, Henk-Jan van Tuyl, haskel...@haskell.org
Hmm, I get

Configuring cuda-0.5.0.0...
setup.exe: configure script not found.

can you help ?

Peter

> I was able to install the cuda package under 32-bit GHC 7.4.2 using the
> 5.0 SDK and use it from within ghci. This required using my fork of the
> cuda repo and following the instructions in my WINDOWS.md. Make sure
> nvcc is in your path (the CUDA installer should have made this so) and
> try 'cabal configure'.


Geoffrey Mainland

unread,
Mar 31, 2013, 3:48:59 PM3/31/13
to Peter Caspers, Henk-Jan van Tuyl, haskel...@haskell.org
You need to generate the configure script using autoconf:

https://www.gnu.org/software/autoconf/manual/autoconf.html#autoconf-Invocation

Peter Caspers

unread,
Apr 1, 2013, 5:33:20 AM4/1/13
to Geoffrey Mainland, Henk-Jan van Tuyl, haskel...@haskell.org
yes, the installation seems to work fine now. However, doing the
following test in ghci

Prelude> :m +Foreign.CUDA
Prelude Foreign.CUDA> props 0
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package cuda-0.5.0.0 ... linking ... done.

results in a crash. The CUDA version I am using is 4.1.28. You think
there is something I could try to analyze this further ?

Thanks a lot for your help
Peter

Geoffrey Mainland

unread,
Apr 1, 2013, 6:25:35 AM4/1/13
to Peter Caspers, Henk-Jan van Tuyl, haskel...@haskell.org
That is not a very elucidating crash message, so I don't see how to
proceed. After ghci print "Loading package cuda-0.5.0.0 ... linking
... done." it just exits? No error dialog, nothing? Did you try building
any of the examples in the cuda package that don't require ghci?

Is your graphics card incompatible with CUDA 5.0, or do you just not
want to update your driver?

Geoff

Peter Caspers

unread,
Apr 1, 2013, 11:27:32 AM4/1/13
to Geoffrey Mainland, Henk-Jan van Tuyl, haskel...@haskell.org
indeed, not very helpful ...

When I installed Cuda the latest driver (296.0) that was running on my
laptop (a W520 ThinkPad) was not sufficient for version 5.0. However as
I noticed today in February Lenovo released a driver update (311.0) and
with that 5.0 is in fact running. :-)

With that the Haskell bindings work well.

Thanks again very much, Geoff
Peter

Geoffrey Mainland

unread,
Apr 1, 2013, 12:01:55 PM4/1/13
to Peter Caspers, Henk-Jan van Tuyl, haskel...@haskell.org
Fantastic, glad you got it working! Maybe it's time for me to send
Trevor a pull request...

Geoff

Manuel M T Chakravarty

unread,
Apr 3, 2013, 10:05:59 PM4/3/13
to Geoffrey Mainland, Haskell Cafe
Geoffrey Mainland <main...@apeiron.net>:
> Fantastic, glad you got it working! Maybe it's time for me to send
> Trevor a pull request...

That sounds like an excellent idea!

Manuel

Trevor L. McDonell

unread,
Apr 3, 2013, 10:37:58 PM4/3/13
to Geoffrey Mainland, haskel...@haskell.org, Henk-Jan van Tuyl
Hi Geoff,

Yes, please do!


-T
Reply all
Reply to author
Forward
0 new messages