Skip to content

Commit

Permalink
Update PyTorch to CUDA 9.0, CuDNN 7.0.3, MKL, build magma with MKL
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Oct 28, 2017
1 parent bb18dd4 commit 9f25a5a
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pkg.tar.xz
84 changes: 84 additions & 0 deletions magma-mkl/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Maintainer: pingplug <pingplug@foxmail.com>
# Contributor: cornholio <vigo.the.unholy.carpathian@gmail.com>

##### Configuration Options
# Specify GPU compute capability Fermi (2.x) or Kepler (3.x) or Maxwell (5.x)
#_GPU_TARGET=Fermi
#_GPU_TARGET=Kepler
#_GPU_TARGET=Maxwell
# Can also be one of these: sm20 sm30 sm35 sm50
_GPU_TARGET=sm61
# Set _USE_CMAKE=1 to use CMake
_USE_CMAKE=0
##### End

pkgname=magma-mkl
pkgver=2.2.0
pkgrel=1
pkgdesc="Provides a dense linear algebra library similar to LAPACK but for heterogeneous/hybrid architectures, starting with current 'Multicore+GPU' systems. (with CUDA and MKL)"
arch=("i686" "x86_64")
url="http://icl.cs.utk.edu/magma/"
license=(custom)
depends=("cuda>=6.5.0" "gsl" "python" "intel-mkl")
makedepends=("gcc-fortran")
options=('staticlibs')
sha1sums=('7f884e4c80dd296939174282d69d19cc1cca71a5')
source=("http://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${pkgver}.tar.gz")
provides=('magma')
conflicts=('magma')

build() {
cd "${srcdir}/magma-${pkgver}"

if ((_USE_CMAKE == 0))
then
# Modify Makefile
cp make.inc-examples/make.inc.mkl-gcc make.inc
sed -i "/#GPU_TARGET ?=/c GPU_TARGET = ${_GPU_TARGET}" make.inc
sed -i '/#CUDADIR/c CUDADIR = /opt/cuda' make.inc

export MKL_ROOT=/opt/intel/mkl
export MKL_INCLUDE=$MKL_ROOT/include
export MKL_LIBRARY=$MKL_ROOT/lib/intel64
source /opt/intel/mkl/bin/mklvars.sh intel64
source /opt/intel/bin/compilervars.sh intel64 # For MKL 2018, this is a symlink to /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/compilervars.sh

make clean
make lib
make sparse
make test
else
# FIXME: there is no shared library
mkdir build && cd build
cmake -DGPU_TARGET=${_GPU_TARGET} \
-DCUDA_HOST_COMPILER=/opt/cuda/bin/gcc \
-DCMAKE_INSTALL_PREFIX=/opt/magma ..
make
fi
}

package() {
if ((_USE_CMAKE == 0))
then
cd "${srcdir}/magma-${pkgver}"
make prefix="${pkgdir}/opt/magma" install
#rm "${pkgdir}/opt/magma/include/*.mod"
else
cd "${srcdir}/magma-${pkgver}/build"
make DESTDIR="${pkgdir}" install
fi

mkdir -p ${pkgdir}/opt/magma/example
cp -ru ${srcdir}/magma-${pkgver}/example/* ${pkgdir}/opt/magma/example/

mkdir -p ${pkgdir}/opt/magma/testing
cp -ru ${srcdir}/magma-${pkgver}/testing/* ${pkgdir}/opt/magma/testing/

rm -rf ${pkgdir}/opt/magma/lib/pkgconfig
mkdir -p ${pkgdir}/usr/share/licenses/magma
cp ${srcdir}/magma-${pkgver}/COPYRIGHT ${pkgdir}/usr/share/licenses/magma/LICENSE

# Add libmagma to LD_LIBRARY_PATH
mkdir -p "${pkgdir}/etc/ld.so.conf.d/"
echo "/opt/magma/lib" > "${pkgdir}/etc/ld.so.conf.d/magma.conf"
}
6 changes: 4 additions & 2 deletions magma/PKGBUILD → magma-openblas/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ _GPU_TARGET=sm61
_USE_CMAKE=0
##### End

pkgname=magma
pkgname=magma-openblas
pkgver=2.2.0
pkgrel=1
pkgdesc="Provides a dense linear algebra library similar to LAPACK but for heterogeneous/hybrid architectures, starting with current 'Multicore+GPU' systems. (with CUDA)"
pkgdesc="Provides a dense linear algebra library similar to LAPACK but for heterogeneous/hybrid architectures, starting with current 'Multicore+GPU' systems. (with CUDA and OpenBLAS)"
arch=("i686" "x86_64")
url="http://icl.cs.utk.edu/magma/"
license=(custom)
Expand All @@ -24,6 +24,8 @@ makedepends=("gcc-fortran")
options=('staticlibs')
sha1sums=('7f884e4c80dd296939174282d69d19cc1cca71a5')
source=("http://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${pkgver}.tar.gz")
provides=('magma')
conflicts=('magma')

build() {
cd "${srcdir}/magma-${pkgver}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Update by mratsim: MKL and MAGMA support
# Maintainer: Stephen Zhang <zsrkmyn at gmail dot com>

pkgbase="python-pytorch-git"
pkgname=("python-pytorch-git" "python2-pytorch-git")
pkgname=("python-pytorch-mkl-magma-cudnn-git" "python2-pytorch-mkl-magma-cudnn-git")
_pkgname="pytorch"
pkgver=0.1.11.r317.gde984558
pkgver=0.1.11.r2305.gdc6c9e8df
pkgrel=1
pkgdesc="Tensors and Dynamic neural networks in Python with strong GPU acceleration"
arch=('x86_64')
url="https://github.com/pytorch/pytorch"
license=('BSD')
makedepends=('python' 'python-setuptools' 'python2' 'python2-setuptools' 'gcc5' 'cmake' 'python-yaml' 'python2-yaml')
depends=('cuda' 'cudnn')
makedepends=('python' 'python-setuptools' 'python2' 'python2-setuptools' 'gcc6' 'cmake' 'python-yaml' 'python2-yaml')
depends=('cuda' 'cudnn' 'intel-mkl')
optdepends=('magma: Further CPU, OpenCL, CUDA, optimized operations')
source=("git://github.com/pytorch/pytorch")
source=("git://github.com/pytorch/pytorch.git")
sha256sums=('SKIP')

pkgver () {
Expand All @@ -25,8 +26,7 @@ pkgver () {


prepare() {
cd "$srcdir/"

cd "$srcdir"
cp -a "${_pkgname}" "${_pkgname}-py2"
cd "${_pkgname}"
sed -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" \
Expand All @@ -36,10 +36,22 @@ prepare() {
}

build() {

export MKL_ROOT=/opt/intel/mkl
export MKL_INCLUDE=$MKL_ROOT/include
export MKL_LIBRARY=$MKL_ROOT/lib/intel64
source /opt/intel/mkl/bin/mklvars.sh intel64
source /opt/intel/bin/compilervars.sh intel64 # For MKL 2018, this is a symlink to /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/compilervars.sh
export CMAKE_INCLUDE_PATH=$MKL_INCLUDE:$CMAKE_INCLUDE_PATH
export CMAKE_LIBRARY_PATH=$MKL_LIBRARY:$CMAKE_LIBRARY_PATH


msg "Building Python 2"
cd "$srcdir/${_pkgname}-py2"
CC=gcc-5 \
CXX=g++-5 \
git submodule update --init

CC=gcc-6 \
CXX=g++-6 \
WITH_CUDA=1 \
CUDA_HOME=/opt/cuda \
WITH_CUDNN=1 \
Expand All @@ -50,8 +62,10 @@ build() {

msg "Building Python 3"
cd "$srcdir/${_pkgname}"
CC=gcc-5 \
CXX=g++-5 \
git submodule update --init

CC=gcc-6 \
CXX=g++-6 \
WITH_CUDA=1 \
CUDA_HOME=/opt/cuda \
WITH_CUDNN=1 \
Expand All @@ -61,7 +75,7 @@ build() {
python setup.py build
}

package_python2-pytorch-git() {
package_python2-pytorch-mkl-magma-cudnn-git() {
conflicts=('python2-pytorch')
provides=('python2-pytorch')
depends+=('python2' 'python2-yaml' 'python2-numpy')
Expand All @@ -70,7 +84,7 @@ package_python2-pytorch-git() {
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
}

package_python-pytorch-git() {
package_python-pytorch-mkl-magma-cudnn-git() {
conflicts=('python-pytorch')
provides=('python-pytorch')
depends+=('python' 'python-yaml' 'python-numpy')
Expand Down
46 changes: 35 additions & 11 deletions python-pytorch-vision-git/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Maintainer: Mamy Ratsimbazafy <mamy (dot) ratsimbazafy_pkgbuild [at] gadz (dot) org>

pkgname=python-pytorch-vision-git
pkgbase=python-pytorch-vision-git
pkgname=('python-pytorch-vision-git' 'python2-pytorch-vision-git')
_pkgname=vision
pkgver=v0.1.8.r9.gcbb05c5
pkgver=v0.1.9.r82.gc1746a2
pkgrel=1
pkgdesc='Datasets, Transforms and Models specific to Computer Vision'
arch=('any')
url='https://github.com/pytorch/vision'
license=('BSD:3-clause')
depends=('python-numpy' 'python-pytorch' 'python-six' 'python-pillow')
makedepends=('git' 'python-setuptools')
conflicts=('python-pytorch-vision')
provides=('python-pytorch-vision')
makedepends=('git' 'python-setuptools' 'python2-setuptools')
source=('git://github.com/pytorch/vision.git'
)
md5sums=('SKIP' )
Expand All @@ -21,17 +19,43 @@ pkgver() {
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
cd "$srcdir/"

build() {
cd $_pkgname
cp -a "${_pkgname}" "${_pkgname}-py2"
cd "${_pkgname}"
sed -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" \
-e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" \
-e "s|#![ ]*/bin/env python$|#!/usr/bin/env python2|" \
-i $(find . -name '*.py')
}

build() {
cd "$srcdir/$_pkgname"
python setup.py build

cd "$srcdir/$_pkgname"-py2
python2 setup.py build

}

package() {
cd $_pkgname
package_python-pytorch-vision-git() {
depends=('python-numpy' 'python-pytorch' 'python-six' 'python-pillow')
conflicts=('python-pytorch-vision')
provides=('python-pytorch-vision')
cd "$srcdir/$_pkgname"

python setup.py install --root=${pkgdir} --optimize=1

install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/python-pytorch-vision
install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}
}
package_python2-pytorch-vision-git() {
depends=('python2-numpy' 'python2-pytorch' 'python2-six' 'python2-pillow')
conflicts=('python2-pytorch-vision')
provides=('python2-pytorch-vision')
cd "$srcdir/$_pkgname"-py2

python2 setup.py install --root=${pkgdir} --optimize=1

install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}
}

0 comments on commit 9f25a5a

Please sign in to comment.