# TMVA GPU utilization

**URL:** <https://root-forum.cern.ch/t/tmva-gpu-utilization/37196>\
**Category:** TMVA\
**Created:** [December 13, 2019, 2:21pm UTC](https://root-forum.cern.ch/t/tmva-gpu-utilization/37196 "2019-12-13T14:21:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbartels](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fbartels](https://root-forum.cern.ch/u/fbartels)\
**Post date:** [December 13, 2019, 2:22pm UTC](https://root-forum.cern.ch/t/tmva-gpu-utilization/37196/1 "2019-12-13T14:22:00Z")

</div>

Hi all,

Unfortunately, I cannot get the GPU implementation of DNN running.

We have an NVidia RTX 2080 Super in our machine running CentOs 7. I installed the latest NVidia driver 440.33.01 instead of nouveau and CUDA 10.2. (as well as BLAS and TBB for the CPU implementation.). CUDA itself seems to work since the default NVIDIA\_CUDA-10.2\_Samples run fine (except those that require graphics output which we have not enabled. Their errors are apparently OpenGL-related – is OpenGL necessary for TMVA?).

I then compiled ROOT 6.18.04 from source and included the cmake flags  
`-Dimt=ON -Dcuda=ON -Dtmva-cpu=ON -Dtmva-gpu=ON -Dtmva=ON`  
as stated in the documentation.

But when I run TMVAClassification.C, it just stops after

```auto
Factory : Train method: DNN_GPU for Classification
                         : 
TFHandler_DNN_GPU : Variable Mean RMS [Min Max]
                         : -----------------------------------------------------------
                         : myvar1: -0.0014053 0.31630 [-1.0000 1.0000]
                         : myvar2: 0.15237 0.30014 [-1.0000 1.0000]
                         : var3: 0.043963 0.35343 [-1.0000 1.0000]
                         : var4: 0.043918 0.29454 [-1.0000 1.0000]
                         : -----------------------------------------------------------
                         : Start of deep neural network training on GPU.
                         : 
TFHandler_DNN_GPU : Variable Mean RMS [Min Max]
                         : -----------------------------------------------------------
                         : myvar1: -0.0014053 0.31630 [-1.0000 1.0000]
                         : myvar2: 0.15237 0.30014 [-1.0000 1.0000]
                         : var3: 0.043963 0.35343 [-1.0000 1.0000]
                         : var4: 0.043918 0.29454 [-1.0000 1.0000]
                         : -----------------------------------------------------------

```

I can see that it does reserve 115 MiB on the GPU but then just nothing happens for hours:

```auto
# nvidia-smi
Fri Dec 13 14:59:59 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 208... Off | 00000000:05:00.0 Off | N/A |
| 33% 35C P8 11W / 250W | 126MiB / 7981MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 28151 C /opt/root_v6_18/bin/root.exe 115MiB |
+-----------------------------------------------------------------------------+

```

DNN\_CPU runs fine for example, it is just the GPU implementation causing this problem. Is there anything that I missed in the installation? Unfortunately, I cannot find any errors in /var/log/ to hint at the problem.

Cheers,  
Falk

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [December 16, 2019, 1:53pm UTC](https://root-forum.cern.ch/t/tmva-gpu-utilization/37196/2 "2019-12-16T13:53:25Z")

</div>

Hi,

I would need to see your macro to understand the issue. Can you please try to switch to MethodDL instead of MethodDNN when booking the neural network in TFactory::BookMethod ?

MethodDL is the new implementation supporting also convolutional and recurrent layers and it is reccomended to use it also for fully connected layers

Best regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![fbartels](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fbartels](https://root-forum.cern.ch/u/fbartels)\
**Post date:** [December 16, 2019, 3:47pm UTC](https://root-forum.cern.ch/t/tmva-gpu-utilization/37196/3 "2019-12-16T15:47:17Z")

</div>

Hi Lorenzo,

I am using the default `$ROOTSYS/tutorials/tmva/TMVAClassification.C` ( [TMVAClassification.C](https://root-forum.cern.ch/uploads/short-url/pz73wpcAvLHphec4wODunFvA7N7.C) (27.8 KB) ) that comes with ROOT 6.18.04 - which itself seems to include TMVA 4.2.1 . The macro already uses `TMVA::Types::kDL` with the option `Architecture=GPU`. `"DNN_GPU"` is apparently just an arbitrary user name.

Hope this helps,  
Falk

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [December 17, 2019, 10:43am UTC](https://root-forum.cern.ch/t/tmva-gpu-utilization/37196/4 "2019-12-17T10:43:09Z")

</div>

Hi,

I cannot reproduce this with 6.18.04. There is probably something not right with your GPU card or the Cuda installation. When using TMVAClassification.C the training on GPU should be really fast. It is less than a second on my GPU card (RTX 2070)  
You could verify CUDA by installing and compiling the CUDA sample programs.  
They are normally in /usr/local/cuda/samples  
See [https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html) for their location.  
You normally need to just type make in the sample directory (after having copied them in a writeable directory)

Lorenzo
