Ci-dessous, les différences entre deux révisions de la page.
developpement:activites:integration:cuda4squeeze [2013/03/22 16:20] sbarends créée |
developpement:activites:integration:cuda4squeeze [2015/01/07 10:04] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Utilisation des librairies Cuda sur une Debian Squeeze ====== | ||
- | |||
- | <note important>Mise à jour le 8 août 2012 : passage en pilote 295.71 suite à un avis de sécurité de Nvidia</note> | ||
- | |||
- | ===== Installation de Cuda 4.2 ===== | ||
- | |||
- | Au 27 mai 2012, le pilote Cuda version 4.2 ne nécessite plus d'inscription préalable pour être téléchargé. | ||
- | |||
- | Le lien suivant défini les différents paquets à installer : | ||
- | * le pilote : la version 295.71 pour [[http://us.download.nvidia.com/XFree86/Linux-x86_64/295.71/NVIDIA-Linux-x86_64-295.71.run|64 bits]] et [[http://us.download.nvidia.com/XFree86/Linux-x86/295.71/NVIDIA-Linux-x86-295.71.run|32 bits]]<code> | ||
- | cd /root | ||
- | # Dans sa version 64 bits | ||
- | wget http://us.download.nvidia.com/XFree86/Linux-x86_64/295.71/NVIDIA-Linux-x86_64-295.71.run | ||
- | # Dans sa version 32 bits | ||
- | wget http://us.download.nvidia.com/XFree86/Linux-x86/295.71/NVIDIA-Linux-x86-295.71.run | ||
- | </code> | ||
- | * la boîte à outils : la version 4.2.9 pour [[http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_64_ubuntu10.04.run|64 bits]] et [[http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_32_ubuntu10.04.run|32 bits]]<code> | ||
- | # Dans sa version 64 bits | ||
- | wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_64_ubuntu10.04.run | ||
- | # Dans sa version 32 bits | ||
- | wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/cudatoolkit_4.2.9_linux_32_ubuntu10.04.run | ||
- | </code> | ||
- | <note warning>La version disponible pour Ubuntu 11.04 n'est pas utilisable sous Debian Squeeze : elle requiert des dépendances trop fortes pour la version 3.4 de la librairie C !</note> | ||
- | * les exemples (?) : version [[http://developer.download.nvidia.com/compute/cuda/4_2/rel/sdk/gpucomputingsdk_4.2.9_linux.run|4.2.9]]<code> | ||
- | wget http://developer.download.nvidia.com/compute/cuda/4_2/rel/sdk/gpucomputingsdk_4.2.9_linux.run | ||
- | </code> | ||
- | |||
- | ==== Installation du pilote ==== | ||
- | |||
- | <note important>Toutes ces commandes sont à effectuer comme ''root''</note> | ||
- | |||
- | |||
- | Pour commencer, installation et configuration minimale :<code>apt-get install module-assistant | ||
- | # téléchargement des prototypes du noyau courant si nécessaire | ||
- | m-a prepare | ||
- | # pour les noyaux récents (par exemple comme le 2.6.32, il faut blacklister nouveau | ||
- | echo blacklist nouveau >> /etc/modprobe.d/blacklist.conf | ||
- | # arret de GDM s'il est lancé | ||
- | /etc/init.d/gdm stop | ||
- | # arret de GDM3 s'il est lancé | ||
- | /etc/init.d/gdm3 stop | ||
- | # arret de KDM s'il est lancé | ||
- | /etc/init.d/kdm stop | ||
- | </code> | ||
- | |||
- | Le redémarrage semble nécessaire pour que le pilote ''nouveau'' ne soit pas chargé. | ||
- | |||
- | Puis, même lancement de l'installation du pilote : | ||
- | * dans sa version 64 bits :<code> | ||
- | sh /root/NVIDIA-Linux-x86_64-295.59.run -a -d -kernel-name=$(uname -r)</code> | ||
- | * dans sa version 32 bits :<code> | ||
- | sh /root/NVIDIA-Linux-x86-295.59.run -a -d -kernel-name=$(uname -r)</code>. | ||
- | ==== Installation de la boîte à outils ==== | ||
- | |||
- | |||
- | <note important>Toutes ces commandes sont à effectuer comme ''root''</note> | ||
- | |||
- | Pour le SDK, toujours aussi simple, mais, pour uniformiser les usages, nous décidons d'installer ces librairies non pas dans ''usr/local/cuda'' mais ''/opt/cuda''. De plus, nous désirons conserver l'ancienne version : <code> | ||
- | cd /opt | ||
- | # Suppression du lien | ||
- | [ -e /opt/cuda ] && rm -r /opt/cuda | ||
- | # Lancer l'installation | ||
- | sh /root/cudatoolkit_4.2.9_linux_64_ubuntu10.04.run | ||
- | # Entrer la racine du repertoire d'installation | ||
- | /opt | ||
- | # Renommer le repertoire en le suffixant du numero de version | ||
- | mv cuda cuda-4.2.9 | ||
- | ln -s cuda-4.2.9 cuda | ||
- | # Creer le document contenant les libraires dynamiques de Cuda (la version 64 bits est pointee) | ||
- | echo /opt/cuda/lib64 > /etc/ld.so.conf.d/cuda.conf | ||
- | # Mettre a jour la base | ||
- | ldconfig | ||
- | # Ajouter le chemin vers les executables de Cuda (notamment nvcc) | ||
- | sed -e "s/:\/bin/:\/bin:\/opt\/cuda\/bin/" -e "s/:\/usr\/games/:\/usr\/games:\/opt\/cuda\/bin/" -i~ /etc/profile | ||
- | # Placer un lien sur la librairie cuda installe par le pilote graphique | ||
- | cd /opt/cuda/lib64 | ||
- | ln -s /usr/lib/libcuda.so libcuda.so | ||
- | </code> | ||
- | |||
- | ==== Installation des exemples ==== | ||
- | |||
- | <note important>Toutes ces commandes sont à effectuer comme ''root''</note> | ||
- | |||
- | Ensuite, même lancement de l'installation des exemples, pour une installation du SDK dans ''/opt'' : <code>cd /opt | ||
- | # Suppression du lien | ||
- | [ -e /opt/NVIDIA_GPU_Computing_SDK ] && rm -r /opt/NVIDIA_GPU_Computing_SDK | ||
- | # Lancement du script d'installation (il est supposé que l'archive est dans /opt) | ||
- | sh /root/gpucomputingsdk_4.2.9_linux.run | ||
- | # Entrer le chemin d'installation | ||
- | /opt/NVIDIA_GPU_Computing_SDK-4.2.9 | ||
- | # Entrer le chemin d'installation des librairies Cuda | ||
- | /opt/cuda | ||
- | # Etablir un lien en ce SDK et la version standard | ||
- | ln -sf NVIDIA_GPU_Computing_SDK-4.2.9 NVIDIA_GPU_Computing_SDK | ||
- | </code> | ||
- | |||
- | Enfin, la compilation des exemples : d'abord ceux de Cuda, ensuite les exemples OpenCL :<code> | ||
- | apt-get --yes install libxi-dev libxmu-dev libglut3-dev | ||
- | cd /opt/NVIDIA_GPU_Computing_SDK/C | ||
- | make | ||
- | cd /opt/NVIDIA_GPU_Computing_SDK/OpenCL | ||
- | make | ||
- | </code> | ||
- | |||
- | ===== Installation de PyCUDA ===== | ||
- | |||
- | Téléchargement des sources sur : http://mathema.tician.de/software/pycuda | ||
- | |||
- | ==== Préparation de la compilation ==== | ||
- | |||
- | <code> | ||
- | apt-get install git libboost-python1.42-dev libboost-thread1.42-dev libboost1.42-all-dev libboost1.42-dev python-setuptools | ||
- | </code> | ||
- | |||
- | |||
- | <note important>Toutes ces commandes sont à effectuer comme ''root''</note> | ||
- | |||
- | ==== Téléchargement des sources ==== | ||
- | |||
- | Directement en téléchargeant par Git | ||
- | <code> | ||
- | cd /opt | ||
- | git clone http://git.tiker.net/trees/pycuda.git | ||
- | cd pycuda | ||
- | git submodule init | ||
- | git submodule update | ||
- | </code> | ||
- | |||
- | En récupérant l'archive | ||
- | <code> | ||
- | cd /root | ||
- | wget http://pypi.python.org/packages/source/p/pycuda/pycuda-2012.1.tar.gz#md5=b67c4fce6c258834339073f2537fa84f | ||
- | cd /opt | ||
- | tar xzf /root/pycuda-2012.1.tar.gz | ||
- | ln -s pycuda-2012.1 pycuda | ||
- | chown -R root.root pycuda | ||
- | cd pycuda | ||
- | </code> | ||
- | ==== Compilation et installation ==== | ||
- | |||
- | <code> | ||
- | export PATH=$PATH:/opt/cuda/bin | ||
- | export PYCUDA=$PWD | ||
- | |||
- | # On 2011-12-12, Andreas Klockner has corrected ! | ||
- | # On 2011-12-08, PyCUDA needs a slightly patch to compile | ||
- | #cd src/cpp | ||
- | #wget http://www.cbp.ens-lyon.fr/emmanuel.quemener/software/GPU/patch-cuda.hpp | ||
- | #patch src/cuda/cuda.hpp patch-cuda.hpp | ||
- | #cd ../.. | ||
- | # Sorry, I don't understand why diff -u/patch -p3 don't work on this tiny patch ! | ||
- | |||
- | # Configuration | ||
- | export CUDA_ROOT=/opt/cuda | ||
- | #./configure.py --cuda-enable-gl --no-use-shipped-boost --cudadrv-lib-dir=/opt/cuda/lib64 --cuda-root=/opt/cuda --cuda-inc-dir=/opt/cuda/include/ --boost-inc-dir=/usr/include --boost-lib-dir=/usr/lib --boost-python-libname=boost_python-py26 --boost-thread-libname=boost_python-mt-py26 --boost-compiler=/opt/cuda/bin/nvcc | ||
- | ./configure.py --cuda-enable-gl --no-use-shipped-boost | ||
- | |||
- | # Compilation | ||
- | make | ||
- | |||
- | # Installation | ||
- | make install | ||
- | # | ||
- | python setup.py build | ||
- | python setup.py install | ||
- | </code> | ||
- | |||
- | ==== Exécution des tests d'intégration ==== | ||
- | |||
- | <code> | ||
- | cd $PYCUDA/test | ||
- | </code> | ||
- | |||
- | Premier exemple : ''python test_cumath.py'' donne<code> | ||
- | ============================= test session starts ============================== | ||
- | platform linux2 -- Python 2.6.6 -- pytest-2.2.3 | ||
- | collected 20 items | ||
- | |||
- | test_cumath.py .................... | ||
- | |||
- | ========================== 20 passed in 37.14 seconds ========================== | ||
- | </code> | ||
- | |||
- | Deuxième exemple : ''python test_driver.py'' donne<code> | ||
- | ============================= test session starts ============================== | ||
- | platform linux2 -- Python 2.6.6 -- pytest-2.2.3 | ||
- | collected 21 items | ||
- | |||
- | test_driver.py ..................... | ||
- | |||
- | ========================== 21 passed in 13.75 seconds ========================== | ||
- | </code> | ||
- | |||
- | Troisième exemple : ''python test_gpuarray.py'' donne <code> | ||
- | ============================= test session starts ============================== | ||
- | platform linux2 -- Python 2.6.6 -- pytest-2.2.3 | ||
- | collected 45 items | ||
- | |||
- | test_gpuarray.py ............................................. | ||
- | |||
- | ========================= 45 passed in 129.98 seconds ========================== | ||
- | </code> | ||
- | |||
- | ==== Exécution des exemples ==== | ||
- | |||
- | <code> | ||
- | cd $PYCUDA/examples | ||
- | python download-examples-from-wiki.py | ||
- | </code> | ||
- | ===== Installation de PyOpenCL ===== | ||
- | |||
- | Téléchargement des sources sur : http://mathema.tician.de/software/pyopencl | ||
- | |||
- | ==== Préparation de la compilation ==== | ||
- | |||
- | <code>apt-get install libboost-thread-dev</code> | ||
- | |||
- | Au 20 juin 2012, la version courante est la ''2012.1'' : | ||
- | |||
- | <code>cd /opt | ||
- | git clone http://git.tiker.net/trees/pyopencl.git | ||
- | cd pyopencl | ||
- | git submodule init | ||
- | git submodule update | ||
- | </code> | ||
- | |||
- | <code> | ||
- | cd /root | ||
- | wget http://pypi.python.org/packages/source/p/pyopencl/pyopencl-2012.1.tar.gz#md5=e6ae70d89d086af4636e4fbb2c806368 | ||
- | cd /opt | ||
- | tar xzf /root/pyopencl-2012.1.tar.gz | ||
- | ln -s pyopencl-2012.1 pyopencl | ||
- | cd pyopencl | ||
- | </code> | ||
- | |||
- | ==== Compilation et installation de PyOpenCL ==== | ||
- | |||
- | Avec l'installation des librairies Cuda comme présentée ci-dessus, la compilation se prépare de la façon suivante : | ||
- | <code>./configure.py --boost-inc-dir=/usr/include --boost-lib-dir=/usr/lib --boost-python-libname=boost_python-mt-py26 --cl-inc-dir=/opt/cuda/include/ --cl-lib-dir=/usr/lib/ --boost-compiler=/opt/cuda/bin/nvcc | ||
- | make | ||
- | make install | ||
- | python setup.py build | ||
- | python setup.py install | ||
- | </code> | ||
- | |||
- | ==== Exécution des exemples ==== | ||
- | |||
- | <code> | ||
- | cd examples | ||
- | python benchmark-all.py | ||
- | </code> | ||
- | |||
- | Sur une carte Quadro 4000 (et un Dell Precision 7500):<code> | ||
- | =============================================================== | ||
- | ('Platform name:', 'NVIDIA CUDA') | ||
- | ('Platform profile:', 'FULL_PROFILE') | ||
- | ('Platform vendor:', 'NVIDIA Corporation') | ||
- | ('Platform version:', 'OpenCL 1.1 CUDA 4.1.1') | ||
- | --------------------------------------------------------------- | ||
- | ('Device name:', 'Quadro 4000') | ||
- | ('Device type:', 'GPU') | ||
- | ('Device memory: ', 2047, 'MB') | ||
- | ('Device max clock speed:', 950, 'MHz') | ||
- | ('Device compute units:', 8) | ||
- | Execution time of test: 0.000847584 s | ||
- | Results OK | ||
- | </code> | ||
- | |||
- | Sur une carte Quadro 2000 (et un Dell Precision M4600):<code> | ||
- | ('Execution time of test without OpenCL: ', 7.520247220993042, 's') | ||
- | =============================================================== | ||
- | ('Platform name:', 'AMD Accelerated Parallel Processing') | ||
- | ('Platform profile:', 'FULL_PROFILE') | ||
- | ('Platform vendor:', 'Advanced Micro Devices, Inc.') | ||
- | ('Platform version:', 'OpenCL 1.1 AMD-APP (831.4)') | ||
- | --------------------------------------------------------------- | ||
- | ('Device name:', 'Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz') | ||
- | ('Device type:', 'CPU') | ||
- | ('Device memory: ', 16042, 'MB') | ||
- | ('Device max clock speed:', 800, 'MHz') | ||
- | ('Device compute units:', 4) | ||
- | /usr/local/lib/python2.6/dist-packages/pyopencl-2012.1-py2.6-linux-x86_64.egg/pyopencl/__init__.py:36: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more. | ||
- | "to see more.", CompilerWarning) | ||
- | Execution time of test: 0.00134103 s | ||
- | Results OK | ||
- | =============================================================== | ||
- | ('Platform name:', 'NVIDIA CUDA') | ||
- | ('Platform profile:', 'FULL_PROFILE') | ||
- | ('Platform vendor:', 'NVIDIA Corporation') | ||
- | ('Platform version:', 'OpenCL 1.1 CUDA 4.2.1') | ||
- | --------------------------------------------------------------- | ||
- | ('Device name:', 'Quadro 2000M') | ||
- | ('Device type:', 'GPU') | ||
- | ('Device memory: ', 2047, 'MB') | ||
- | ('Device max clock speed:', 1100, 'MHz') | ||
- | ('Device compute units:', 4) | ||
- | Execution time of test: 0.00202246 s | ||
- | Results OK | ||
- | </code> | ||
- | |||
- | Vous aurez noter que l'installation préalable d'un SDK AMD a permis de disposer d'un support OpenCL sur le processeur. | ||
- | |||
- | ====== Installation de PyFFT ====== | ||
- | |||
- | [[http://packages.python.org/pyfft/|PyFFT]] permet l'exploitation de PyCUDA et PyOpenCL pour effectuer tranquillement ses FFT directement à partir de ses scripts Python. | ||
- | |||
- | Pour son installation, suivre la page : http://www.cbp.ens-lyon.fr/emmanuel.quemener/dokuwiki/doku.php?id=pyfft4squeeze | ||