Mac PyCUDA with Snow Leopard and EPD
[[!toc ]]
/!\ This page has not been updated for the removal of the Boost dependency in 0.94. If you use this page, please perform the necessary updates. Thanks! -- AndreasKloeckner 2010-09-21 00:17:38
Install Dependencies
Install XCode (from the Snow Leopard Install DVD that came with the machines) and get all Software Updates for it to ensure it's on the latest version.
Install these applications (download from the appropriate locations):
epd-6.1-1-macosx-i386.dmg
cudatoolkit_3.0_macos_32.pkg
cudadriver_3.0.14_macos.dmg
gpucomputingsdk_3.0_macos_32.pkg
Update Shell Startup Script
If the machine is running BASH, then you would open your ~/.profile
file (creating it if it does not exist) and add the following lines (make sure to open a new terminal once you have done this):
export PATH="/usr/local/cuda/bin:${PATH}"
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$HOME/pool/lib:${DYLD_LIBRARY_PATH}
export PYTHONPATH=$HOME/lib/python:$PYTHONPATH
But if it's running the old and out-dated and inferior TCSH you'll need to edit your .cshrc file to have this:
set path=(/usr/local/cuda/bin $path)
setenv DYLD_LIBRARY_PATH /usr/local/cuda/lib:$HOME/pool/lib
setenv PYTHONPATH $HOME/lib/python
Create the lib/python directory:
mkdir -p ~/lib/python
Install Boost
Download boost_1_42_0.tar.bz2
, extract it:
tar xvjf boost_1_42_0.tar.bz2
cd boost_1_42_0
install it (this is two lines)
./bootstrap.sh --prefix=$HOME/pool --libdir=$HOME/pool/lib
--with-libraries=signals,thread,python
./bjam -j2 address-model=32_64 architecture=x86 variant=release
link=shared install
Fix the linking, which seems to be broken:
cd ~/pool/lib
install_name_tool -change
/System/Library/Frameworks/Python.framework/Versions/2.6/Python
/Library/Frameworks/Python.framework/Versions/Current/Python
libboost_python.dylib
Install PyCuda
Download pycuda-VERSION.tar.gz
(tested with 0.94rc), extract it
tar xvzf pycuda-0.94rc.tar.gz
cd pycuda-0.94rc
# Run configure
./configure.py --cuda-root=/usr/local/cuda/
Edit siteconf.py to point at your boost python and thread libraries in ~/pool/lib and LDFLAGS:
CUDA_ENABLE_GL = True
CUDADRV_LIB_DIR = []
CUDADRV_LIBNAME = ['cuda']
CXXFLAGS = ["-arch", "x86_64", "-arch", "i386"]
LDFLAGS = ["-arch", "x86_64", "-arch", "i386"]
# Change SDK dir if needed:
CXXFLAGS.extend(['-isysroot', '/Developer/SDKs/MacOSX10.6.sdk'])
LDFLAGS.extend(['-isysroot', '/Developer/SDKs/MacOSX10.6.sdk'])
Install to ~/lib/python directory:
python setup.py install --home=~
Make sure it works:
python test/test_driver.py
(Instructions by Per Sederberg)
Note: the test in the last line above requires that you install pytest:
sudo easy_install pytest
(Contributed by David Ketcheson)