0

I’m trying to install a CUDA package in Python called PyCUDA under OSX Maverics on a MacBook Pro 15ā€ retina, but when trying to compile the files I get the following error:

ld: warning: directory not found for option '-F /Library/Frameworks -framework CUDA'
ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1

I think that at this stage PyCUDA is trying to compile some of it's C components.

I researched the error online and the solution proposed was to add -F/Library/Frameworks and -framework CUDA to the arguments list, but the make still fails with the error above.

I have CUDA 5.5 installed and Xcode command line tools as well. Also I am installing from the command line (not Xcode) using:

python setup.py install

Which, in turn calls clang to compile some of the components.

I think the @rpath part of the path is not processed correctly.

Any way I could resolve this error?

MA81
  • 93
  • 8

3 Answers3

2

I got similar error, but I managed to install pycuda using this http://wiki.tiker.net/PyCuda/Installation/Mac

Especially I used siteconf.py as specified in the instructions.

BOOST_INC_DIR = []                                                              
BOOST_LIB_DIR = []                                                              
BOOST_COMPILER = 'gcc43'                                                        
USE_SHIPPED_BOOST = True                                                        
BOOST_PYTHON_LIBNAME = ['boost_python-py27']                                    
BOOST_THREAD_LIBNAME = ['boost_thread']                                         
CUDA_TRACE = False                                                              
CUDA_ROOT = '/usr/local/cuda'                                                   
CUDA_ENABLE_GL = False                                                          
CUDA_ENABLE_CURAND = True                                                       
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib']                    
CUDADRV_LIBNAME = ['cuda']                                                      
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib']                     
CUDART_LIBNAME = ['cudart']                                                     
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib']                     
CURAND_LIBNAME = ['curand']                                                     
CXXFLAGS = ["-arch", "x86_64", "-arch", "i386"]                                 
LDFLAGS = ["-F/Library/Frameworks", "-arch", "x86_64", "-arch", "i386"]         
CXXFLAGS.extend(['-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'])
LDFLAGS.extend(['-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'])
wideblue
  • 57
  • 2
  • 9
  • Thanks. For some reason my compiler was targeting the 10.5 OSX version, leading to compilation errors. Removing the "-arch", "i386" parts fixed this problem for me. – John von N. May 23 '15 at 11:12
1

Just add export LDFLAGS="-F/Library/Frameworks/" to your .profile.

Then pip can successfully install pycuda, at least on my Macbook with Yosemite.

Leonard Xu
  • 11
  • 1
0

You can use this procedure with Python2.7 or Python3.4

First, I installed boost libraries:

$brew install boost
$brew install boost-python

Second, you create a file $HOME/.aksetup-defaults.py with content:

CUDA_ROOT = '/usr/local/cuda'
CUDADRV_LIBNAME = ['cuda']
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib']
CUDART_LIBNAME = ['cudart']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib']
CUDA_ENABLE_CURAND = True
CUDA_ENABLE_GL = True
CUDA_INC_DIR = ['${CUDA_ROOT}/include']
CUDA_TRACE = False
CURAND_LIBNAME = ['curand']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib']
USE_SHIPPED_BOOST = True

Finally, install pycuda using pip

$python -m pip install pycuda

Voila! Start using pycuda

ilciavo
  • 3,069
  • 7
  • 26
  • 40