Rétroportage de pilote Nvidia & Cuda sur une Debian Jessie

Attention ! Cassé au 21 avril 2016 pour la partie PyCUDA et PyOpenCL

Rétroportage de CUDA 6.5 sous Jessie

La Debian Jessie ne dispose que de la version 6.0.37 de CUDA et du pilote 340.46. Ces versions peuvent rapidement sembler insuffisantes pour ceux qui désirent utiliser les dernières fonctionnalités de CUDA 6 ou simplement utiliser les dernières cartes video Nvidia.

Voici la méthode permettant d'installer à partir d'un rétro-portage les paquets Nvidia ainsi que tout l'environnement associé. Au 17 novembre 2015, il est à nouveau possible de récupérer la version 352.55 se trouvant dans l'archive experimental : le module NVIDIA se construit correctement à l'installation par DKMS. L'environnement de développement, le 6.5.19, sera rétroporté directement de l'archive experimental.

Pour une compilation dans SIDUS, ne pas oublier de monter le /proc

Purge des paquets Nvidia et CUDA originels

dpkg -l | egrep "nvidia|cuda|cupti|nvtoolsext|nvvm|nvctrl|nvcuvid|curand|cublas|cufft|cudart|cuinj|cusparse|libnpp" | awk '{ print $2 }' | xargs -I '{}' apt-get -y purge '{}'
dpkg -l | grep opencl | grep -v openclip | awk '{ print $2 }' | xargs -I '{}' apt-get -y purge '{}'

Préparation du système

Il est nécessaire d'insérer les sources des paquets sid et expérimentaux pour disposer de la dernière version de CUDA packagée (la 6.5.14).

apt-get install -y pbuilder pciutils debhelper quilt libgtk2.0-dev libjansson-dev libvdpau-dev libxv-dev libxxf86vm-dev dh-autoreconf

[ $(grep jessie /etc/apt/sources.list | grep deb-src | wc -l) -gt 0 ] && echo "Already present" || echo "deb-src http://ftp.fr.debian.org/debian/ sid main contrib non-free" >> /etc/apt/sources.list
[ $(grep sid /etc/apt/sources.list | grep deb-src | wc -l) -gt 0 ] && echo "Already present" || echo "deb-src http://ftp.fr.debian.org/debian/ sid main contrib non-free" >> /etc/apt/sources.list
[ $(grep experimental /etc/apt/sources.list | grep deb-src | wc -l) -gt 0 ] && echo "Already present" || echo "deb-src http://ftp.fr.debian.org/debian/ experimental main contrib non-free" >> /etc/apt/sources.list
aptitude -y update

Rétroportage des composants Système

mkdir -p /root/nvidia/debian
cd /root/nvidia
apt-get source glx-alternatives
apt-get build-dep glx-alternatives -y
cd glx-alternatives-*
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

glx-alternative-fglrx_0.7.1_amd64.deb
glx-alternative-mesa_0.7.1_amd64.deb
glx-alternative-nvidia_0.7.1_amd64.deb
glx-diversions_0.7.1_amd64.deb
update-glx_0.7.1_amd64.deb

Rétroportage des composants Nvidia

cd /root/nvidia
apt-get source -y nvidia-xconfig nvidia-support nvidia-modprobe libvdpau-dev
apt-get build-dep -y libvdpau-dev
cd /root/nvidia/libvdpau-*
debuild
cd ..
dpkg -i libvdpau1_*_amd64.deb libvdpau-dev_*_amd64.deb
mv *deb debian
# Telechargement des composants nvidia-graphics-drivers
apt-get source nvidia-graphics-drivers
apt-get -y build-dep nvidia-xconfig nvidia-support nvidia-modprobe nvidia-settings nvidia-graphics-drivers
cd /root/nvidia/
cd nvidia-graphics-drivers-*
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

libcuda1_355.11-2_amd64.deb
libegl1-nvidia_355.11-2_amd64.deb
libegl-nvidia0_355.11-2_amd64.deb
libgl1-nvidia-glx_355.11-2_amd64.deb
libgles1-nvidia_355.11-2_amd64.deb
libgles2-nvidia_355.11-2_amd64.deb
libglvnd-nvidia_355.11-2_amd64.deb
libnvcuvid1_355.11-2_amd64.deb
libnvidia-compiler_355.11-2_amd64.deb
libnvidia-eglcore_355.11-2_amd64.deb
libnvidia-encode1_355.11-2_amd64.deb
libnvidia-fbc1_355.11-2_amd64.deb
libnvidia-ifr1_355.11-2_amd64.deb
libnvidia-ml1_355.11-2_amd64.deb
nvidia-alternative_355.11-2_amd64.deb
nvidia-cuda-mps_355.11-2_amd64.deb
nvidia-detect_355.11-2_amd64.deb
nvidia-driver_355.11-2_amd64.deb
nvidia-driver-bin_355.11-2_amd64.deb
nvidia-kernel-dkms_355.11-2_amd64.deb
nvidia-kernel-source_355.11-2_amd64.deb
nvidia-kernel-support_355.11-2_amd64.deb
nvidia-legacy-check_355.11-2_amd64.deb
nvidia-libopencl1_355.11-2_amd64.deb
nvidia-opencl-common_355.11-2_amd64.deb
nvidia-opencl-icd_355.11-2_amd64.deb
nvidia-smi_355.11-2_amd64.deb
nvidia-vdpau-driver_355.11-2_amd64.deb
xserver-xorg-video-nvidia_355.11-2_amd64.deb
cd /root/nvidia/nvidia-modprobe-*/
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

nvidia-modprobe_361.28-1_amd64.deb
apt-get source -y nvidia-settings
apt-get build-dep -y nvidia-settings
cd /root/nvidia/nvidia-settings-*
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

libxnvctrl0_346.59-1_amd64.deb
libxnvctrl-dev_346.59-1_amd64.deb
nvidia-settings_346.59-1_amd64.deb
cd /root/nvidia/nvidia-xconfig-*/
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Le paquet créé est le suivant :

nvidia-xconfig_340.93-1_amd64.deb
cd /root/nvidia/nvidia-support-*/
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

nvidia-installer-cleanup_20151021+4_amd64.deb
nvidia-kernel-common_20151021+4_amd64.deb
nvidia-support_20151021+4_amd64.deb

Installation des composants Nvidia

cd /root/nvidia/debian

rmmod nvidia
sync
rmmod -f nouveau

dpkg -i nvidia-installer-cleanup_*_amd64.deb
dpkg -i glx-diversions_*_amd64.deb update-glx_*.deb glx-alternative-mesa_*_amd64.deb
dpkg -i nvidia-support_*_amd64.deb
dpkg -i glx-alternative-nvidia_*_amd64.deb

dpkg -i nvidia-modprobe_*_amd64.deb
dpkg -i nvidia-legacy-check-*_amd64.deb
dpkg -i nvidia-alternative_*_amd64.deb

dpkg -i libgl1-nvidia-glx_*_amd64.deb 

apt-get install -y xserver-xorg-core libaudit1 libxkbfile1 x11-xkb-utils xfonts-base xserver-common

dpkg -i nvidia-kernel-common_*_amd64.deb 
dpkg -i nvidia-kernel-source_*_amd64.deb
dpkg -i nvidia-kernel-support_*_amd64.deb
dpkg -i nvidia-kernel-dkms_*_amd64.deb

ls -1 lib*$(dpkg -l | grep  nvidia-kernel-dkms | awk '{ print $3 }')*deb | xargs -I '{}' dpkg -i '{}'

apt-get -f install

dpkg -i xserver-xorg-video-nvidia_*

dpkg -i nvidia-vdpau-driver_*_amd64.deb nvidia-driver_*_amd64.deb nvidia-driver-bin_*_amd64.deb

ls *$(dpkg -l | grep  nvidia-kernel-dkms | awk '{ print $3 }')*deb  | grep -v ^lib | grep -v nvidia-kernel | grep -v libopencl | xargs -I '{}' dpkg -i '{}'

dpkg -i nvidia-driver-bin_*deb nvidia-driver_*deb nvidia-xconfig* nvidia-settings* libxnvctrl* nvidia-smi_*

apt-get -f install

Rétroportage des composants Cuda

cd /root/nvidia
apt-get -y source nvidia-cuda-toolkit
apt-get -y build-dep nvidia-cuda-toolkit
cd nvidia-cuda-toolkit-*
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

libcublas7.0_7.0.28-4_amd64.deb
libcudart7.0_7.0.28-4_amd64.deb
libcufft7.0_7.0.28-4_amd64.deb
libcufftw7.0_7.0.28-4_amd64.deb
libcuinj64-7.0_7.0.28-4_amd64.deb
libcupti7.0_7.0.28-4_amd64.deb
libcupti-dev_7.0.28-4_amd64.deb
libcupti-doc_7.0.28-4_all.deb
libcurand7.0_7.0.28-4_amd64.deb
libcusolver7.0_7.0.28-4_amd64.deb
libcusparse7.0_7.0.28-4_amd64.deb
libnppc7.0_7.0.28-4_amd64.deb
libnppi7.0_7.0.28-4_amd64.deb
libnpps7.0_7.0.28-4_amd64.deb
libnvblas7.0_7.0.28-4_amd64.deb
libnvrtc7.0_7.0.28-4_amd64.deb
libnvtoolsext1_7.0.28-4_amd64.deb
libnvvm3_7.0.28-4_amd64.deb
nvidia-cuda-dev_7.0.28-4_amd64.deb
nvidia-cuda-doc_7.0.28-4_all.deb
nvidia-cuda-gdb_7.0.28-4_amd64.deb
nvidia-cuda-toolkit_7.0.28-4_amd64.deb
nvidia-nsight_7.0.28-4_amd64.deb
nvidia-opencl-dev_7.0.28-4_amd64.deb
nvidia-profiler_7.0.28-4_amd64.deb
nvidia-visual-profiler_7.0.28-4_amd64.deb

Installation des composants Cuda & OpenCL

apt-get install -y opencl-headers ocl-icd-opencl-dev 
cd /root/nvidia/debian
ls *7.0.28*deb | grep -v opencl | xargs -I '{}' dpkg -i '{}'
# Il arrive que l'installeur rale sur nvidia-cuda-toolkit. Si c'est le cas, la commande suivante s'impose
apt-get -f install

Rétroportage du composant Python PyOpenCL

cd /root/nvidia
apt-get -y build-dep pycuda
apt-get -y install python-setuptools python3-setuptools
wget http://snapshot.debian.org/archive/debian/20150617T043723Z/pool/main/p/pyopencl/pyopencl_2015.1-2.debian.tar.xz
wget http://snapshot.debian.org/archive/debian/20150617T043723Z/pool/main/p/pyopencl/pyopencl_2015.1-2.dsc
wget http://snapshot.debian.org/archive/debian/20150610T042543Z/pool/main/p/pyopencl/pyopencl_2015.1.orig.tar.xz
tar Jxf pyopencl_2015.1.orig.tar.xz
cd pyopencl-*/
tar Jxf ../pyopencl_2015.1-2.debian.tar.xz
debuild
cd ..
ls -1 *.deb
mv *.deb debian

Les paquets créés sont les suivants :

python3-pyopencl_2015.1-2_amd64.deb
python3-pyopencl-dbg_2015.1-2_amd64.deb
python-pyopencl_2015.1-2_amd64.deb
python-pyopencl-dbg_2015.1-2_amd64.deb
python-pyopencl-doc_2015.1-2_all.deb

Rétroportage du composants Python PyCUDA

Réinstallation du composant ICD associé au périphérique Nvidia

cd /root/nvidia/debian
dpkg -i nvidia-opencl-common_*_amd64.deb nvidia-opencl-icd_*_amd64.deb

Il n'est pas possible de rétroporter la dernière version de pycuda en Jessie à cause des dépendances entre PyCUDA et d'autres librairies récentes n'acceptant pas le rétroportage.

cd /root/nvidia
apt-get -y build-dep pycuda
apt-get -y install python-setuptools python3-setuptools
wget http://snapshot.debian.org/archive/debian/20150710T034220Z/pool/contrib/p/pycuda/pycuda_2015.1.2-1.debian.tar.xz
wget http://snapshot.debian.org/archive/debian/20150710T034220Z/pool/contrib/p/pycuda/pycuda_2015.1.2-1.dsc
wget http://snapshot.debian.org/archive/debian/20150710T034220Z/pool/contrib/p/pycuda/pycuda_2015.1.2.orig.tar.xz
tar Jxf pycuda_2015.1.2.orig.tar.xz 
cd pycuda-*/
tar Jxf ../pycuda_2015.1.2-1.debian.tar.xz
debuild
cd ..
ls -1 *.deb
mv *.deb debian
python3-pycuda_2015.1.2-1_amd64.deb
python3-pycuda-dbg_2015.1.2-1_amd64.deb
python-pycuda_2015.1.2-1_amd64.deb
python-pycuda-dbg_2015.1.2-1_amd64.deb
python-pycuda-doc_2015.1.2-1_all.deb

Installation des composants Python

cd /root/nvidia/debian
# Les paquets suivants issus de AMD sont necessaires pour le premier et bien utile pour le second
apt-get install -y ocl-icd-libopencl1 ocl-icd-dev opencl-headers
apt-get install -y amd-opencl-icd amd-clinfo
# Les paquets icd standard ocl-icd-opencl-dev ocl-icd-libopencl1
dpkg -i python-pyopencl*.deb  python3-pyopencl*.deb
cd /root/nvidia/debian
apt-get install -y python-pytest python3-pytest python3-appdirs python-appdirs 
dpkg -i python-pycuda*deb python3-pycuda*deb

Exécution des exemples

Sur une machine équipée de 3 cartes vidéo et 3 implémentations d'OpenCL pour CPU (AMD, Intel, PortableCL)

python /usr/share/doc/python-pyopencl-doc/examples/benchmark.py 
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 2.0 AMD-APP (1800.11)
---------------------------------------------------------------
Device name: Fiji
Device type: GPU
Device memory:  4045 MB
Device max clock speed: 1000 MHz
Device compute units: 64
Device max work group size: 256
Device max work item sizes: [256, 256, 256]
Data points: 8388608
Workers: 256
Preferred work group size multiple: 64
Execution time of test: 0.00037168 s
Results OK
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 2.0 AMD-APP (1800.11)
---------------------------------------------------------------
Device name: Intel(R) Xeon(R) CPU E5-2665 0 @ 2.40GHz
Device type: CPU
Device memory:  128966 MB
Device max clock speed: 2309 MHz
Device compute units: 32
Device max work group size: 1024
Device max work item sizes: [1024, 1024, 1024]
Data points: 8388608
Workers: 256
Preferred work group size multiple: 1
Execution time of test: 0.0192504 s
Results OK
===============================================================
Platform name: Intel(R) OpenCL
Platform profile: FULL_PROFILE
Platform vendor: Intel(R) Corporation
Platform version: OpenCL 1.2 LINUX
---------------------------------------------------------------
Device name:        Intel(R) Xeon(R) CPU E5-2665 0 @ 2.40GHz
Device type: CPU
Device memory:  128966 MB
Device max clock speed: 2400 MHz
Device compute units: 32
Device max work group size: 8192
Device max work item sizes: [8192, 8192, 8192]
/usr/lib/python2.7/dist-packages/pyopencl/__init__.py:63: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
  "to see more.", CompilerWarning)
Data points: 8388608
Workers: 256
Preferred work group size multiple: 128
Execution time of test: 0.00310517 s
Results OK
===============================================================
Platform name: Portable Computing Language
Platform profile: FULL_PROFILE
Platform vendor: The pocl project
Platform version: OpenCL 1.2 pocl 0.10
---------------------------------------------------------------
Device name: pthread-Intel(R) Xeon(R) CPU E5-2665 0 @ 2.40GHz
Device type: CPU
Device memory:  128966 MB
Device max clock speed: 3100 MHz
Device compute units: 32
Device max work group size: 1024
Device max work item sizes: [1024, 1024, 1024]
Data points: 8388608
Workers: 256
Preferred work group size multiple: 8
Execution time of test: 0.007638 s
Results OK
===============================================================
Platform name: NVIDIA CUDA
Platform profile: FULL_PROFILE
Platform vendor: NVIDIA Corporation
Platform version: OpenCL 1.2 CUDA 7.5.20
---------------------------------------------------------------
Device name: GeForce GTX 980 Ti
Device type: GPU
Device memory:  6143 MB
Device max clock speed: 1190 MHz
Device compute units: 22
Device max work group size: 1024
Device max work item sizes: [1024, 1024, 64]
Data points: 8388608
Workers: 256
Preferred work group size multiple: 32
Execution time of test: 0.000522592 s
Results OK
===============================================================
Platform name: NVIDIA CUDA
Platform profile: FULL_PROFILE
Platform vendor: NVIDIA Corporation
Platform version: OpenCL 1.2 CUDA 7.5.20
---------------------------------------------------------------
Device name: Quadro 600
Device type: GPU
Device memory:  1023 MB
Device max clock speed: 1280 MHz
Device compute units: 2
Device max work group size: 1024
Device max work item sizes: [1024, 1024, 64]
Data points: 8388608
Workers: 256
Preferred work group size multiple: 32
Execution time of test: 0.00468445 s
Results OK
developpement/activites/integration/cuda4jessie.txt · Dernière modification: 2016/04/21 19:10 par equemene