# Feature request - enable cuda if detected

**URL:** <https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [February 16, 2019, 3:11pm UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764 "2019-02-16T15:11:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [February 16, 2019, 3:11pm UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764/1 "2019-02-16T15:11:18Z")

</div>

Is there any inherent reason that the cuda flag is not enabled by default if CUDA is present in the system?

I was looking at this file - [https://github.com/root-project/root/blob/7d7b70500e1413094a01ce7c7b795ef58cd51529/cmake/modules/SearchInstalledSoftware.cmake](https://github.com/root-project/root/blob/7d7b70500e1413094a01ce7c7b795ef58cd51529/cmake/modules/SearchInstalledSoftware.cmake) and it seems like the cuda flag is relevant only when the tmva and the tmva-gpu flags are enabled.  
If that is the case, would it make sense for the cuda flag to be removed and check for CUDA in the system when just the tmva and the tmva-gpu flags are enabled?

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [February 16, 2019, 7:37pm UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764/2 "2019-02-16T19:37:09Z")

</div>

Hi,

In summary: No, I don’t think so and I am in favour of _not_ requiring two flags to make tmva compile with gpu support.

Indeed, the current defaults are `cuda=OFF` and `tmva-gpu=ON`. However, the DL library is enabled _iff_ `tmva-gpu and cude` holds true. Currently the only user of cuda, to my knowledge, is the tmva dl-library.

In this context, it could make sense to remove the `cuda` flag completely. We should at least make `tmva-gpu` imply `cuda` as currently it is absolutely required.

One reason to have the separation of the `tmva-gpu` and `cuda` flags is that if there were several backends available, the user should be able to choose their preference. However, also in this case there should be a reasonable default.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [February 17, 2019, 8:51am UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764/3 "2019-02-17T08:51:45Z")

</div>

Related pull request - [https://github.com/root-project/root/pull/3438](https://github.com/root-project/root/pull/3438)

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [February 17, 2019, 6:57pm UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764/4 "2019-02-17T18:57:38Z")

</div>

We need to discuss with @moneta to decide what to do. In principle, we shouldn’t have duplication of flags for similar functionality. On the other hand, if we remove the cuda flag, we may have to add it back later when something else (e.g. fitting) supports CUDA in ROOT. That said, it seems tmva-gpu and cuda interact in a strange way and we need to sort that out indeed.

---

<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:** [February 18, 2019, 9:17am UTC](https://root-forum.cern.ch/t/feature-request-enable-cuda-if-detected/32764/5 "2019-02-18T09:17:56Z")

</div>

Hi,

I agree with @amadio. I thin kit is better to keep the cuda flag in case other parts of ROOT will support Cuda in the future. Also TMVA-GPU it is good to have it because in principle you could have cuda for some other parts of ROOT and TMVA-CPU for others.

I think the flags work fine, if something does not work as expected we should fix.  
If CUDA is enable I think by default also TMVA-GPU is enabled  
The opposite it is not true (i.e if TMVA-GPU is set to ON it will not be set if CUDA=Off). Maybe this could be changed

Lorenzo
