Instructions for making CUDA 2.3 work on Snow Leopard How to fix permissions and nvcc linker errors

Hi all,

here’s a summary of what needs to be done to get CUDA 2.3 working nice on Snow Leopard.
I did not find out this stuff, I’m just summing up the stuff gathered from various other forum posts.

Fix 1:
NVCC is not compatible with gcc and g++ 4.2, but these are the default compilers on Snow Leopard and nvcc uses the defaults.
The solution is to make versions 4.0 the system defaults again (as was the case with Leopard)

To remove the symbolic links to versions 4.2 and re-create the links to versions 4.0 execute:

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.0 /usr/bin/gcc

sudo rm /usr/bin/g++
sudo ln -s /usr/bin/g+±4.0 /usr/bin/g++

Fix 2:
CUDA is not yet capable of 64bit development under OS X, but it looks like the compilers now default to creating 64bit code.
To prevent that, the parameter -m32 needs to be passed to all compilers (gcc, g++ and nvcc).

In order to build the CUDA SDK samples on SL, the following adjustments are needed to the SDKs common make file:

Edit /Developer/GPU Computing/C/common/common.mk

The lines
NVCCFLAGS :=
CXXFLAGS := $(CXXWARN_FLAGS)
CFLAGS := $(CWARN_FLAGS)

Need to be changed to
NVCCFLAGS := -m32
CXXFLAGS := -m32 $(CXXWARN_FLAGS)
CFLAGS := -m32 $(CWARN_FLAGS)

FIx 3:
Due to a bug in the CUDA Driver (or Toolkit?) installer, some permissions are not correctly set, which prevents the CUDA kernel extension from being loaded after a system restart.

The permissions can be fixed with these commands:

sudo chmod g-w /System/Library/StartupItems/CUDA/*
sudo chmod g-w /System/Library/StartupItems/CUDA/

Hopefully that’s all - but actually I messed so much with my system lately that I cannot be sure I didn’t miss something.
So if CUDA still does not work please give feedback here so we can adjust/expand this summary.

FIX 4: (added 10.Sept.09)
Wrong permissions on the “/usr/local/cuda/lib” folder
This one seems to happen under some circumstances only - on 5 CUDA installs it happened to me once. Anyway, after installing the CUDA driver and toolkit make sure check if this folder does can be read by all users.

Hope that helps.

Mark

Just one addition: driver 2.3.1 is the one and only compatible with Snow Leopard.

In your Fix 1 do you mean to link gcc to gcc-4.2 or to gcc-4.0?

Thanks - that was a typo. I corrected the instructions.

Also corrected the path to the common makefile.

It now reads /Developer/GPU Computing/C/common/common.mk, as installed by default.

Does not work for me.
can’t find

From the brevity of your post I ask myself if you do expect someone to help you.

I guess not really - or?

This was all pretty handy in terms of getting things to start compiling, but I’m noticing a LOT of problems with GL header files. Is anyone else running into this?

This is using -I/Developer/GPU/C/common/inc (GPU just being a symlink to GPU Computing so that there is no space in the pathname.)

/usr/X11R6/include/GL/gl.h(1746): error: invalid redeclaration of type name “PFNGLTEXIMAGE3DPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1175): here

/usr/X11R6/include/GL/gl.h(1850): error: invalid redeclaration of type name “PFNGLSECONDARYCOLORPOINTERPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1460): here

/usr/X11R6/include/GL/gl.h(1852): error: invalid redeclaration of type name “PFNGLPOINTPARAMETERFVPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1443): here

/usr/X11R6/include/GL/gl.h(1856): error: invalid redeclaration of type name “PFNGLMULTIDRAWARRAYSPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1440): here

/usr/X11R6/include/GL/gl.h(1857): error: invalid redeclaration of type name “PFNGLMULTIDRAWELEMENTSPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1441): here

/usr/X11R6/include/GL/gl.h(1936): error: invalid redeclaration of type name “PFNGLGETVERTEXATTRIBPOINTERVPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1747): here

/usr/X11R6/include/GL/gl.h(1974): error: invalid redeclaration of type name “PFNGLGETUNIFORMLOCATIONPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1744): here

/usr/X11R6/include/GL/gl.h(1978): error: invalid redeclaration of type name “PFNGLGETSHADERSOURCEPROC”
/Developer/GPU/C/common/inc/GL/glew.h(1742): here

Thanks,
-Brett

I did everything exactly as explained, and I still can’t compile. When I do make on the examples, I get the following error:

[codebox]make -C src/3DFD/

ld: warning: in …/…/lib/libcutil.a, file is not of required architecture

make -C src/alignedTypes/

ld: warning: in …/…/lib/libcutil.a, file is not of required architecture

Undefined symbols:

“_cutCheckCmdLineFlag”, referenced from:

  _main in alignedTypes.cu.o

  _main in alignedTypes.cu.o

  _main in alignedTypes.cu.o

“_cutGetCmdLineArgumenti”, referenced from:

  _main in alignedTypes.cu.o

“_cutStartTimer”, referenced from:

  void runTest<RGBA32_2>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32>(int, int)in alignedTypes.cu.o

  void runTest<RGB32>(int, int)in alignedTypes.cu.o

  void runTest<LA32>(int, int)in alignedTypes.cu.o

  void runTest<unsigned int>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGB32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<LA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<unsigned short>(int, int)in alignedTypes.cu.o

  void runTest<unsigned char>(int, int)in alignedTypes.cu.o

“_cutCreateTimer”, referenced from:

  _main in alignedTypes.cu.o

“_cutGetTimerValue”, referenced from:

  void runTest<RGBA32_2>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32>(int, int)in alignedTypes.cu.o

  void runTest<RGB32>(int, int)in alignedTypes.cu.o

  void runTest<LA32>(int, int)in alignedTypes.cu.o

  void runTest<unsigned int>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGB32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<LA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<unsigned short>(int, int)in alignedTypes.cu.o

  void runTest<unsigned char>(int, int)in alignedTypes.cu.o

“_cutDeleteTimer”, referenced from:

  _main in alignedTypes.cu.o

“_cutStopTimer”, referenced from:

  void runTest<RGBA32_2>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32>(int, int)in alignedTypes.cu.o

  void runTest<RGB32>(int, int)in alignedTypes.cu.o

  void runTest<LA32>(int, int)in alignedTypes.cu.o

  void runTest<unsigned int>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGB32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<LA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<unsigned short>(int, int)in alignedTypes.cu.o

  void runTest<unsigned char>(int, int)in alignedTypes.cu.o

“_cutResetTimer”, referenced from:

  void runTest<RGBA32_2>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32>(int, int)in alignedTypes.cu.o

  void runTest<RGB32>(int, int)in alignedTypes.cu.o

  void runTest<LA32>(int, int)in alignedTypes.cu.o

  void runTest<unsigned int>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8>(int, int)in alignedTypes.cu.o

  void runTest<RGBA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGB32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<LA32_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<RGBA8_misaligned>(int, int)in alignedTypes.cu.o

  void runTest<unsigned short>(int, int)in alignedTypes.cu.o

  void runTest<unsigned char>(int, int)in alignedTypes.cu.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

make[1]: *** […/…/bin/darwin/release/alignedTypes] Error 1

make: *** [src/alignedTypes/Makefile.ph_build] Error 2

[/codebox]

Don’t know what to do now…did I miss something? I double checked on the -m32 flags because it mentions incompatible architectures…

I even added -m32 in a few other places just in case.

@Brett:
Yes, I think NVIDIA is doing a little mess with the OpenGL headers.
Under OS X glew, glu, glut are all shipped with the system but the CUDA SDK ships and uses with it’s own copies of those. So probably you’ll run into trouble if you create an app that uses both the Mac headers AND the SDK common includes. Is that the case? Do the SDK samples (that use OpenGL) compile?

@fercook
No idea. Did you try ‘make clean’ and then ‘make’?

I did the Fix 1 and got:

make -C src/3DFD/
make[1]: g++: No such file or directory
make[1]: *** […/…/bin/darwin/release/3dfd] Error 1
make: *** [src/3DFD/Makefile.ph_build] Error 2

Thanks.

Also, when I go to

bash-3.2$ ls /usr/bin

I do not see g+±4.0 listed, i’m not sure if that is significant. Thanks!

I just tried it, but it seems to have made things worse. Now this is the only output from make:

[codebox]a - obj/release/bank_checker.cpp.o

a - obj/release/cmd_arg_reader.cpp.o

a - obj/release/cutil.cpp.o

a - obj/release/stopwatch.cpp.o

a - obj/release/stopwatch_linux.cpp.o

a - obj/release/multithreading.cpp.o

make -C src/3DFD/

nvcc fatal : redefinition of argument ‘machine’

make[1]: *** [obj/release/3dfd.cu.o] Error 255

make: *** [src/3DFD/Makefile.ph_build] Error 2

[/codebox]

I don’t have a weird setup or anything…these bugs are annoying.

You need to install Xcode first, then follow the instructions.

The examples do compile, however none of them use glx.h, and it seems that nVidia isn’t distributing it. glx.h in turn includes gl.h, which then causes the issue. Not really sure what I can do about this, but this is COMPLETELY killing my productivity at this point.

-Brett

Edited post: added Fix#4.

Looks like the X11 has a subfolder /gl with those headers as does the CUDA SDK - that should be the cause.

Can’t you just use the OpenGL framework instead of X11? I think you are looking for trouble programing X11 under OS X… not that I’ve done it…

Is this problem in any way related to Snow Leopard - so did it work on previous installs?

I’m have the impression this is not really a SL/CUDA problem but actually something that possibly never worked.

If that is the case, it might make more cense for you to open a new discussion thread.

(Not that I care of you asking here, but I think you will have more success in finding out how this works on another thread)

Mark

I did install Xcode from the Mac OS X Snow Leopard DVD. Should I reinstall it?

Hi Mark,

This was definitely working perfectly under 10.5, and only became a problem in Snow Leopard. The code in question is multi-platform, so I’m not sure if I can change it without causing issues on other platforms.

I might be able to do massive #ifdefs, but that definitely won’t be pretty.

Anyhow, I do appreciate the input, and I’ll at least take a gander and see if it might be feasible. As you might imagine, it’s just frustrating to have a lot of work created by something that was previously working perfectly.

-Brett