Skip to content

Instantly share code, notes, and snippets.

@gaebor
Last active August 31, 2018 13:27
Show Gist options
  • Save gaebor/61323e72a7b415e6487e9590ce181857 to your computer and use it in GitHub Desktop.
Save gaebor/61323e72a7b415e6487e9590ce181857 to your computer and use it in GitHub Desktop.
how to install libgpuarray and make theano to perform 64bit, double precision, float64 calculations on (cuda capable) GPU
# the followings are expected to be installed
#
# virtualenv, git
# OpenBlas: https://github.com/xianyi/OpenBLAS
# cuda: https://developer.nvidia.com/cuda-downloads
ARGV=("$@")
function check_command
{
$@
if [[ $? -ne 0 ]]
then
exit 1
fi
}
MY_PREFIX="$HOME/.local"
if [ ! -e $MY_PREFIX ]
then
mkdir $MY_PREFIX
fi
if [ ! -e $MY_PREFIX/lib ]
then
mkdir $MY_PREFIX/lib
fi
if [ ! -e $MY_PREFIX/include ]
then
mkdir $MY_PREFIX/include
fi
# also put these into ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MY_PREFIX/lib
export CPATH=$CPATH:$MY_PREFIX/include
export LIBRARY_PATH=$LIBRARY_PATH:$MY_PREFIX/lib
envname=theano
if [ $1 ]
then
envname=$1
fi
### virtualenv ###
if [ ! -e $envname/bin/activate ]
then
check_command virtualenv ${ARGV[@]:1} $envname
fi
check_command source $envname/bin/activate
check_command pip install -U pip
check_command pip install -U mako
check_command pip install -U nvidia-ml-py cython six nose nose_parameterized numpy scipy psutil jupyter notebook ipython
### gpuarray ###
if [ ! -e libgpuarray ]
then
check_command git clone https://github.com/Theano/libgpuarray
fi
cd libgpuarray
check_command git pull origin master
if [ ! -e Build ]
then
mkdir Build
fi
cd Build
check_command cmake .. -DCMAKE_INSTALL_PREFIX=$MY_PREFIX -DCMAKE_BUILD_TYPE=Release
check_command make
check_command make install
cd ..
check_command python setup.py build_ext -L $MY_PREFIX/lib -I $MY_PREFIX/include
check_command python setup.py install
cd ..
### cnmem ###
# cnmem is included since Theano version 0.8
# for the default backend: lib.cnmem=0.5
# for the new backend use it with: gpuarray.preallocate=XY
### Theano ###
pip install -U theano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment