# TotalSegmentator error at first run: ‘DummyFile’ object has no attribute ‘flush’

**URL:** <https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399>\
**Category:** Support\
**Tags:** segmentation, deep-learning\
**Created:** [March 15, 2023, 11:55am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399 "2023-03-15T11:55:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoniozidaric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/antoniozidaric/32/18794_2.png) [@antoniozidaric](https://discourse.slicer.org/u/antoniozidaric)\
**Post date:** [March 15, 2023, 11:55am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/1 "2023-03-15T11:55:21Z")

</div>

Hi Iassoan, I’m trying to use the TotalSegmentator Tool but i receive this error below the Apply button:

RuntimeError: FIND was unable to find an engine to execute this computation

Exception ignored in: \<totalsegmentator.libs.DummyFile object at 0x000002765B9EE4F0\>

AttributeError: ‘DummyFile’ object has no attribute ‘flush’

I checked if could be an error due to the GPU’s memory but on my laptop is 10Gb of Memory.  
Thanks for you time  
AZ

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [March 15, 2023, 2:01pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/2 "2023-03-15T14:01:20Z")

</div>

Could you provide some more details? What is the brand and model of the GPU?

---

<div class="post-metadata">

**Author:** ![antoniozidaric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/antoniozidaric/32/18794_2.png) [@antoniozidaric](https://discourse.slicer.org/u/antoniozidaric)\
**Post date:** [March 15, 2023, 2:38pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/3 "2023-03-15T14:38:04Z")

</div>

Sure. The model is “GPU intel(r) uhd graphics 620”

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [March 15, 2023, 2:55pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/4 "2023-03-15T14:55:56Z")

</div>

Unfortunately, GPU processing will require an NVIDIA GPU, so you could switch to CPU processing which will take longer to run (30 minutes vs. 2 minutes).

Switch here:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/d/9d66d7eb21328ccbba07cb9e671e3d8670f5c8f4.png)

---

<div class="post-metadata">

**Author:** ![antoniozidaric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/antoniozidaric/32/18794_2.png) [@antoniozidaric](https://discourse.slicer.org/u/antoniozidaric)\
**Post date:** [March 15, 2023, 3:13pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/5 "2023-03-15T15:13:04Z")

</div>

I don’t know why but it doesn’t switch the computation on CPU, it still remain on GPU and ask me if i want to enable the ‘fast’ mode.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 15, 2023, 3:17pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/6 "2023-03-15T15:17:07Z")

</div>

You need to uninstall the GPU version of pytorch, restart Slicer, and install the CPU version of pytorch - as described  
[here](https://github.com/lassoan/SlicerTotalSegmentator#segmentation-fails-while-predicting).

---

<div class="post-metadata">

**Author:** ![antoniozidaric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/antoniozidaric/32/18794_2.png) [@antoniozidaric](https://discourse.slicer.org/u/antoniozidaric)\
**Post date:** [March 15, 2023, 3:23pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/7 "2023-03-15T15:23:56Z")

</div>

Ok, now it is correctly working. Thank you so much for your time

---

<div class="post-metadata">

**Author:** ![J\_UWA](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j_uwa/32/65925_2.png) [@J\_UWA](https://discourse.slicer.org/u/J_UWA)\
**Post date:** [May 9, 2023, 4:59am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/8 "2023-05-09T04:59:08Z")

</div>

Hey @lassoan, I have uninstalled the GPU version of pytorch, restart Slicer, and install the CPU version of pytorch. However, still encountering the same error.

 ![Screenshot 2023-05-09 125818](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/c/9c59e6862492e07d227a0383ebc25adfe2afa35a.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 9, 2023, 10:45am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/9 "2023-05-09T10:45:06Z")

</div>

What is the installed pytorch version?

---

<div class="post-metadata">

**Author:** ![J\_UWA](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j_uwa/32/65925_2.png) [@J\_UWA](https://discourse.slicer.org/u/J_UWA)\
**Post date:** [May 9, 2023, 4:02pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/10 "2023-05-09T16:02:52Z")

</div>

I found your other post here.

> [@TotalSegmentator error at first run: Command ...Python\\Scripts\\TotalSegmentator... returned non-zero exit status 120](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/7):
>
> For the time being, since i have slicer installed in a computer which, by default, has no internet acess, i cannot download the sample data set and test TotalSegmentator with it. As soon as i have acess to internet, i will try. The messages that appear after the Apply button are as follows: Processing started Writing input file to C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_21+10+39.789/total-segmentator-input.nii Creating segmentations with TotalSegmentator AI… Tota…

It’s been resolved. Thank you !

---

<div class="post-metadata">

**Author:** ![yongchanghuang95](https://avatars.discourse-cdn.com/v4/letter/y/bbce88/32.png) [@yongchanghuang95](https://discourse.slicer.org/u/yongchanghuang95)\
**Post date:** [June 21, 2024, 9:46am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/11 "2024-06-21T09:46:30Z")

</div>

I’m having the same problem，somebody can analysis for me？

> The “DummyFile” object does not have a “flush” attribute  
> returned non-zero exit status 120.

I can not find the information about **The “DummyFile” object does not have a “flush” attribute**

the follow pytorch version detail :

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/9/89c6284eb5f0fa0ba6c86ef07fec8357120577e9.png)

error detail :

```Processing
Writing input file to C:/Users/26686/AppData/Local/Temp/Slicer/ __SlicerTemp__ 2024-06-21_17+33+47.251/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI (pre-run)...
Total Segmentator arguments: ['-i', 'C:/Users/26686/AppData/Local/Temp/Slicer/ __SlicerTemp__ 2024-06-21_17+33+47.251/total-segmentator-input.nii', '-o', 'C:/Users/26686/AppData/Local/Temp/Slicer/ __SlicerTemp__ 2024-06-21_17+33+47.251/segmentation', '--fast']
D:\Slicer 5.6.2\lib\Python\Lib\site-packages\requests\ __init__.py:102: RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.2.0)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
D:\Slicer 5.6.2\lib\Python\Lib\site-packages\requests\ __init__.py:102: RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.2.0)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
D:\Slicer 5.6.2\lib\Python\Lib\site-packages\requests\ __init__.py:102: RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.2.0)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "D:\Slicer 5.6.2\lib\Python\Lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "D:\Slicer 5.6.2\lib\Python\Lib\multiprocessing\pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\nnunetv2\inference\export_prediction.py", line 39, in export_prediction_from_softmax
    segmentation = label_manager.convert_logits_to_segmentation(predicted_array_or_file)
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\nnunetv2\utilities\label_handling\label_handling.py", line 182, in convert_logits_to_segmentation
    return self.convert_probabilities_to_segmentation(probabilities)
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\nnunetv2\utilities\label_handling\label_handling.py", line 175, in convert_probabilities_to_segmentation
    segmentation = predicted_probabilities.argmax(0)
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 6.85 GiB for an array with shape (287, 233, 233, 118) and data type float32
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Slicer 5.6.2\lib\Python\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Slicer 5.6.2\lib\Python\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Slicer 5.6.2\lib\Python\Scripts\TotalSegmentator.exe\ __main__.py", line 7, in <module>
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\totalsegmentator\bin\TotalSegmentator.py", line 127, in main
    totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\totalsegmentator\python_api.py", line 293, in totalsegmentator
    seg_img, ct_img = nnUNet_predict_image(input, output, task_id, model=model, folds=folds,
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 395, in nnUNet_predict_image
    nnUNetv2_predict(tmp_dir, tmp_dir, task_id, model, folds, trainer, tta,
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 178, in nnUNetv2_predict
    predict_from_raw_data(dir_in,
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py", line 347, in predict_from_raw_data
    [i.get() for i in r]
  File "D:\Slicer 5.6.2\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py", line 347, in <listcomp>
    [i.get() for i in r]
  File "D:\Slicer 5.6.2\lib\Python\Lib\multiprocessing\pool.py", line 771, in get
    raise self._value
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 6.85 GiB for an array with shape (287, 233, 233, 118) and data type float32
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000001E2BB5F6B20>
AttributeError: 'DummyFile' object has no attribute 'flush'

If you use this tool please cite: https://pubs.rsna.org/doi/10.1148/ryai.230024

Using 'fast' option: resampling to lower resolution (3mm)
Resampling...
  Resampled in 4.25s
Predicting...
type or paste code here

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 21, 2024, 12:32pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/12 "2024-06-21T12:32:50Z")

</div>

`AttributeError: 'DummyFile' object has no attribute 'flush'` is a [false alarm](https://github.com/lassoan/SlicerTotalSegmentator/blob/main/README.md#attributeerror-dummyfile-object-has-no-attribute-flush), you can ignore this message.

In general, you need to look for the first error in the output - all further errors may be consequences of the first one. In your case, the first error was that you have ran out of memory:

> [@yongchanghuang95](#):
>
> ```auto
> numpy.core._exceptions._ArrayMemoryError: Unable to allocate 6.85 GiB for an array with shape (287, 233, 233, 118) and data type float32
> Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000001E2BB5F6B20>
> AttributeError: 'DummyFile' object has no attribute 'flush'
> 
> ```

To solve the issue, you need to reduce the image size or increase available memory size. See detailed instructions [here](https://github.com/lassoan/SlicerTotalSegmentator/blob/main/README.md#numpycore_exceptions_arraymemoryerror-unable-to-allocate).

---

<div class="post-metadata">

**Author:** ![yongchanghuang95](https://avatars.discourse-cdn.com/v4/letter/y/bbce88/32.png) [@yongchanghuang95](https://discourse.slicer.org/u/yongchanghuang95)\
**Post date:** [June 24, 2024, 1:25am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-dummyfile-object-has-no-attribute-flush/28399/13 "2024-06-24T01:25:48Z")

</div>

Many thanks for taking the time to respond，I try set up the bigger virtual memory to run again。
