Outils pour utilisateurs

Outils du site


cupy_vs_numpy

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
cupy_vs_numpy [2020/04/07 13:30] – [Ressources] sergecupy_vs_numpy [2020/09/06 13:51] (Version actuelle) – [Comment adapter un fichier numpy en cupy] serge
Ligne 1: Ligne 1:
 ====== Cupy: calcul numpy avec CUDA ====== ====== Cupy: calcul numpy avec CUDA ======
-<WRAP center round box 60centeraling+<WRAP center round box 70centeralign
-CuPy – NumPy-like API accelerated with CUDA+**CuPy – NumPy-like API accelerated with CUDA**
 </WRAP> </WRAP>
  
-===== De quoi on cause ici ? =====+[[https://developer.download.nvidia.com/video/gputechconf/gtc/2019/presentation/s9738-using-gpu-power-for-numpy-syntax-calculations.pdf|s9738-using-gpu-power-for-numpy-syntax-calculations.pdf]] sur developer.download.nvidia.com 
 + 
 +[[https://docs-cupy.chainer.org/en/stable/reference/difference.html|Difference between CuPy and NumPy — CuPy 7.8.0 documentation]] sur docs-cupy.chainer.org 
 ===== Ressources ===== ===== Ressources =====
 +  * **Un pdf de présentation de [[https://developer.download.nvidia.com/video/gputechconf/gtc/2019/presentation/s9738-using-gpu-power-for-numpy-syntax-calculations.pdf|Nvidia]]**
 +
 +{{:media_10:using-gpu-power-for-numpy-syntax-calculations-10.png?400|}}
 +{{:media_10:using-gpu-power-for-numpy-syntax-calculations-16.png?400|}}
 +{{:media_10:using-gpu-power-for-numpy-syntax-calculations-11.png?400|}}
   * **[[https://cupy.chainer.org/|cupy.chainer.org]]**   * **[[https://cupy.chainer.org/|cupy.chainer.org]]**
   * **[[https://docs-cupy.chainer.org/en/stable/|Read the Docs de CuPy]]**   * **[[https://docs-cupy.chainer.org/en/stable/|Read the Docs de CuPy]]**
   * **[[https://pypi.org/project/cupy/|pypi.org: cupy]]**   * **[[https://pypi.org/project/cupy/|pypi.org: cupy]]**
-  * **Un pdf de présentation de [[https://developer.download.nvidia.com/video/gputechconf/gtc/2019/presentation/s9738-using-gpu-power-for-numpy-syntax-calculations.pdf|Nvidia]]** 
- 
-{{:media_10:using-gpu-power-for-numpy-syntax-calculations-10.png?600|}} 
-{{:media_10:using-gpu-power-for-numpy-syntax-calculations-16.png?600|}} 
-{{:media_10:using-gpu-power-for-numpy-syntax-calculations-11.png?600|}} 
  
 ===Version de CUDA=== ===Version de CUDA===
Ligne 21: Ligne 24:
   * **[[https://github.com/rapidsai/cudf/tree/master|github.com: cudf]]**   * **[[https://github.com/rapidsai/cudf/tree/master|github.com: cudf]]**
  
-{{ :media_10:rapids_arrow.png?400 |}}+{{ :media_10:rapids_arrow.png?500 |}}
  
-=====Mesure des temps d'exécution d'un script python avec timeit=====+  * **scipy** 
 +  * **opencv** 
 +=====Installation===== 
 +  sudo pip3 install cupy-cuda102 
 + 
 +=====Comment adapter un fichier numpy en cupy===== 
 +[[https://docs-cupy.chainer.org/en/stable/reference/difference.html|docs-cupy.chainer.org: Difference between CuPy and NumPy]] 
 + 
 + 
 +=====Exemple avec l'intelligence du sémaphore===== 
 +  * Exemple avec: [[l_intelligence_du_semaphore|L'intelligence du sémaphore]] 
 +  * [[https://github.com/sergeLabo/semaphore_cupy|Les sources sur GitHub: semaphore_cupy]] 
 + 
 +====Numpy==== 
 +Avec le script semaphore_ia.py 
 +<code> 
 +AMD FX(tm)-8320 Eight-Core Processor 
 + 
 +Calcul avec numpy ... numpy ... numpy ... numpy ...  
 +Training: Shot 60000 Lettre 60000; Testing: Shot 10000 Lettre 10000 
 +Training... 
 +type(weight_list :) <class 'list'>  
 +len(weight_list) = 3  
 +    0 100  
 +    1 100  
 +    2 27 
 +weights.npy enregistré 
 +Testing... 
 +Learningrate: 0.023 Résultat 87.4 
 +Calcul en: 139.8 s 
 +</code> 
 + 
 +====Cupy==== 
 +Avec le script cupy_ia.py 
 +<code> 
 +cupy 7.3 
 +Successfully installed cupy-7.3.0 fastrlock-0.4 
 +Nvidia 1060 GTX 
 + 
 +Calcul avec cupy ... cupy ... cupy ... cupy ...  
 +Training: Shot 60000 Lettre 60000; Testing: Shot 10000 Lettre 10000 
 +Training... 
 +type(weight_list :) <class 'list'>  
 +len(weight_list) = 3  
 +    0 100 <class 'cupy.core.core.ndarray'>  
 +    1 100 <class 'cupy.core.core.ndarray'>  
 +    2 27 <class 'cupy.core.core.ndarray'> 
 +weights_cupy.npy enregistré 
 +Testing... 
 +Learningrate: 0.023 Résultat 89.9 
 +Calcul en: 91.7 s 
 +</code> 
 + 
 +**Soit un gain de 34% avec cupy** 
 + 
 +Il faut vérifier que toutes les datas sont bien chargées dans la RAM GPU: cupy.array  
 +[[https://docs-cupy.chainer.org/en/stable/tutorial/basic.html|docs-cupy.chainer.org: basic]] 
 +===== OpenCV ===== 
 +https://docs-cupy.chainer.org/en/stable/reference/ndimage.html#module-cupyx.scipy.ndimage
  
-<WRAP center round todo 60%> 
-suite .... 
-</WRAP> 
  
  
-{{tag>python sb}}+{{tag> ia python sb }}
cupy_vs_numpy.1586266201.txt.gz · Dernière modification : 2020/04/07 13:30 de serge