# How to disable print messages from ITK functions

**URL:** https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590
**Category:** Engineering
**Created:** [January 7, 2020, 7:36pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590 "2020-01-07T19:36:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 7, 2020, 7:36pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/1 "2020-01-07T19:36:47Z")

</div>

I am using GPUAnisotropicSmoothingFilter for running some benchmarks and the printout similar to the below appears quite a lot disrupting the outptu from the benchmark reporting tool I use. Is there a way to disable such print outs to console ?

```auto
Defines: #define DIM_2
#define BUFPIXELTYPE float
#define OUTPIXELTYPE float
#define PIXELDIM 1

Defines: #define DIM_2
#define PIXELTYPE float

Defines: #define DIM_2
#define BLOCK_SIZE 16
#define PIXELTYPE float
#define ARGTYPE float

Defines: #define DIM_2
#define BUFPIXELTYPE float
#define OUTPIXELTYPE float
#define PIXELDIM 1

Defines: #define DIM_2
#define PIXELTYPE float

Defines: #define DIM_2
#define BLOCK_SIZE 16
#define PIXELTYPE float
#define ARGTYPE float

Defines: #define DIM_2
#define BUFPIXELTYPE float
#define OUTPIXELTYPE float
#define PIXELDIM 1

Defines: #define DIM_2
#define PIXELTYPE float

Defines: #define DIM_2
#define BLOCK_SIZE 16
#define PIXELTYPE float
#define ARGTYPE float

```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 7, 2020, 7:59pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/2 "2020-01-07T19:59:13Z")

</div>

Those defines are mentioned e.g. here:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/c95b99852a9109a8fc176a06f88b2aa6d442154b/Modules/Filtering/GPUAnisotropicSmoothing/src/GPUScalarAnisotropicDiffusionFunction.cl#L20-L26>

  
but I don’t know what could print them to the console except OpenCL compiler. Which OpenCL implementation are you using? Did you set any debugging options to it? Are you sure this does not come from your script?

---

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 7, 2020, 8:02pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/3 "2020-01-07T20:02:27Z")

</div>

nvidia opencl impl. I use other opencl programs and another library, arrayfire, they don’t get printed over there unless programmer explicitly does it. This happens in ITK examples too.

---

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 7, 2020, 8:23pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/4 "2020-01-07T20:23:19Z")

</div>

Actually I found some std::couts in the code.

> <https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/GPUAnisotropicSmoothing/include/itkGPUGradientNDAnisotropicDiffusionFunction.hxx#L109>

It is probably coming from those. These are not guarded with any condition, so I don’t have an option to disable them.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 7, 2020, 9:30pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/5 "2020-01-07T21:30:40Z")

</div>

I guess you will need to modify the source code then. It would be good if you also [submitted](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md) your changes as a pull request.

---

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 7, 2020, 10:08pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/6 "2020-01-07T22:08:25Z")

</div>

Sure, will send a PR soon on github.

---

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 8, 2020, 2:17pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/7 "2020-01-08T14:17:41Z")

</div>

@dzenanz I hit a roadblock with git hooks.

```
Utilities/KWStyle/ITKOverwrite.txt
./Utilities/Hooks/pre-commit-style.bash: line 127: /home/pradeep/gitroot/ITK/413/KWStyle-build/KWStyle: No such file or directory
pre-commit hook failure
-----------------------

KWStyle check failed.

Line numbers in the errors shown refer to the file:
Modules/Core/GPUCommon/include/itkGPUReduction.hxx.kws

```

I am not sure how to resolve this. Any help is appreciated.

The change I made to the relevant file is just deletion of std::cout line. You can look at the changes [here](https://github.com/9prady9/ITK/commit/6b3132f2ac072e3ed51b0b3580a0eddcafd63f75)

I temporarily made the commit (skipping verification) in my fork to hyperlink them here.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 8, 2020, 2:23pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/8 "2020-01-08T14:23:51Z")

</div>

It looks like KWStyle was not built properly, or you made multiple binary trees from one source tree so things got confused. I made a [PR](https://github.com/InsightSoftwareConsortium/ITK/pull/1543) from your branch.

---

<div class="post-metadata">

### Author: ![pradeep](https://discourse.itk.org/user_avatar/discourse.itk.org/pradeep/32/508_2.png) [@pradeep](https://discourse.itk.org/u/pradeep)
#### Post date: [January 8, 2020, 2:27pm UTC](https://discourse.itk.org/t/how-to-disable-print-messages-from-itk-functions/2590/9 "2020-01-08T14:27:31Z")

</div>

I was switching tags and using the same binary tree, perhaps the I messed up the KWStyle build somehow - I am not fluent with its usage.

Thank you for raising the PR.
