Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using antsApplyTransforms to large data #564

Closed
david-hoffman opened this issue Apr 10, 2018 · 26 comments
Closed

Error when using antsApplyTransforms to large data #564

david-hoffman opened this issue Apr 10, 2018 · 26 comments

Comments

@david-hoffman
Copy link

I get this error when using antsApplyTransforms to large data.

** ERROR: NWAD: wrote only 0 of 3650505600 bytes to file
@cookpa
Copy link
Member

cookpa commented Apr 10, 2018

This appears to be a NIFTI library error. Are you sure you have sufficient disk space to write the file?

@david-hoffman
Copy link
Author

@cookpa I believe I do (~8TB free)

@cookpa
Copy link
Member

cookpa commented Apr 10, 2018

OK, then I think the error is caused by integer overflow:

https://github.com/InsightSoftwareConsortium/ITK/blob/a652fd46a9b47acf68f290ca41aa8e5f8a38a56d/Modules/ThirdParty/MINC/src/libminc/nifti/nifti1_io.c#L5169

if size_t is 32 bits, then it would not be able to represent the size of the file.

Do you have the latest ANTs? How did you compile?

@david-hoffman
Copy link
Author

I compiled earlier today following the instructions here: https://github.com/ANTsX/ANTs/wiki/Compiling-ANTs-on-Windows-10

@david-hoffman
Copy link
Author

There's no error if I run the command on a linux box. Something strange about WSL.

@dorianps
Copy link
Collaborator

dorianps commented Apr 10, 2018 via email

@david-hoffman
Copy link
Author

@dorianps I don't think it's a swap issue, I have plenty of RAM (512 GB). Plus, the swap in WSL is 2GB and the swap on the Linux box I used is 4GB.

@cookpa
Copy link
Member

cookpa commented Apr 11, 2018

Related?

microsoft/WSL#597

It seems the WSL was setting the Linux swap size to a small value, resulting in memory allocation failures. The thread above suggests this is fixed in the "creators update", which might be worth a try if you don't already have it.

@dorianps
Copy link
Collaborator

dorianps commented Apr 11, 2018 via email

@david-hoffman
Copy link
Author

This is what I get, again I don't think it's a memory issue

hoffmand@HOFFMAND-WW1:~$ free -m
             total       used       free     shared    buffers     cached
Mem:        524204      82316     441888         17         33        184
-/+ buffers/cache:      82098     442105
Swap:         8192         21       8170

@dorianps
Copy link
Collaborator

dorianps commented Apr 11, 2018 via email

@dorianps
Copy link
Collaborator

dorianps commented Apr 11, 2018 via email

@david-hoffman
Copy link
Author

@dorianps it did show as an error during compilation so I installed it (I also updated the instructions here).

I have run into problems with some python libraries under windows because the default integer is uint32 not uint64. I didn't think this would extend to WSL, but it may have.

@dorianps
Copy link
Collaborator

dorianps commented Apr 11, 2018 via email

@david-hoffman
Copy link
Author

@dorianps I doubt that, I had just run antsRegistration in the same terminal with no issues (albeit on smaller data).

@cookpa
Copy link
Member

cookpa commented Apr 11, 2018

Thanks for the Wiki update @david-hoffman .

From the WSL issue above,

By default native Linux will not allowing you to map an address range larger than your swap file size.

As I read it, the swap size is the limiting factor here. According to your free output above this is 8Gb, but earlier you mentioned it being 2 Gb. Did you change it? Can you increase it further and see if the problem goes away?

@ptsii
Copy link

ptsii commented Feb 9, 2019

Did anyone solve this? I just got the same issue. I don't think it is memory, as it happened with one file (of several I was trying to save) that is relatively small:
** ERROR: NWAD: wrote only 0 of 3612672 bytes to file
(that can't be big enough to be a swap problem, can it?)

@zz10001
Copy link

zz10001 commented Nov 8, 2019

Did anyone solve this? I just got the same issue. I don't think it is memory, as it happened with one file (of several I was trying to save) that is relatively small:
** ERROR: NWAD: wrote only 0 of 3612672 bytes to file
(that can't be big enough to be a swap problem, can it?)

Have you sovle it? I have met the same trouble like this.
image
but it really enough memrory and exist this file

@dorianps
Copy link
Collaborator

dorianps commented Nov 8, 2019 via email

@zz10001
Copy link

zz10001 commented Nov 8, 2019

Sorry, It not on WSL, it occurs when I crop image to 64128128 use simpleitk

@cookpa
Copy link
Member

cookpa commented Nov 8, 2019

I think there's probably more than one way to get this error. If the buffer can only write a subset of the data, this error will be generated. But the numbers reported may not be accurate in case of overflow or if there are I/O errors other than a short write.

If you're seeing this error with ITK outside of ANTs then you might want to ask on the ITK forum.

https://discourse.itk.org

@ptsii
Copy link

ptsii commented Nov 8, 2019 via email

@zz10001
Copy link

zz10001 commented Nov 9, 2019

Thanks for your help.

@david-hoffman
Copy link
Author

Dead issue

@tashrifbillah
Copy link

tashrifbillah commented Jun 9, 2020

Same problem on Cent OS 7 Linux:

11821 Total elapsed time: 534.8
11822 ** ERROR: NWAD: wrote only 68812448 of 92274688 bytes to file
11823 ** ERROR: NWAD: wrote only 129105568** ERROR: NWAD: wrote only 392864 of 276824064 bytes to file
11824 Transform reader for /tmp/tmp6a11_1hd/warp1.nii.gz caught an ITK exception:
11825
11826 itk::ExceptionObject (0x351f3d0)
11827 Location: "unknown"
11828 File: /data/pnl/soft/pnlpipe3/pnlpipe/soft_dir/ANTs-build/ITKv5/Modules/IO/TransformBase/include/itkTransformFileReader.hxx
11829 Line: 129
11830 Description: itk::ERROR: TransformFileReaderTemplate(0x3512e80): Could not create Transform IO object for reading file /tmp/tmp6      a11_1hd/warp1.nii.gz
11831   Tried to create one of the following:
11832     HDF5TransformIOTemplate
11833     HDF5TransformIOTemplate
11834     MatlabTransformIOTemplate
11835     MatlabTransformIOTemplate
11836     TxtTransformIOTemplate
11837     TxtTransformIOTemplate
11838   You probably failed to set a file suffix, or
11839     set the suffix to an unsupported type.
11840
11841
11842 ** ERROR: NWAD: wrote only 67337888 of 92274688 bytes to file
11843 ** ERROR: NWAD: wrote only 64519840 of 92274688 bytes to file
11844 ** ERROR: NWAD: wrote only 64224928 of 92274688 bytes to file
11845 ** ERROR: NWAD: wrote only 50888352 of 92274688 bytes to file
11846 ** ERROR: NWAD: wrote only 62881440 of 92274688 bytes to file
11847 ** ERROR: NWAD: wrote only 65732256 of 92274688 bytes to file
11848 ** ERROR: NWAD: wrote only 63995552 of 92274688 bytes to file
11849 ** ERROR: NWAD: wrote only 44203680 of 92274688 bytes to file
11850 ** ERROR: NWAD: wrote only 63110816 of 92274688 bytes to file
11851 ** ERROR: NWAD: wrote only 63078048 of 92274688 bytes to file

On the following host:

GiB Mem :    251.6 total,    111.1 free,     79.1 used,     61.5 buff/cache
GiB Swap:     14.6 total,      6.8 free,      7.8 used.    169.0 avail Mem

My NIFTI data type:

data_type       INT16
dim0            3
dim1            176
dim2            256
dim3            256

As @cookpa mentioned, I think it is related to my little swap memory.

Edit:
My issue was space shortage in my /tmp/ directory.

@caixh39
Copy link

caixh39 commented Aug 31, 2021

It seem that each nii.gz file registrated will generate some temp files in /tmp/*Warp.nii.gz and Affine.mat in ubuntu system, as below:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants