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

Errors when trying to predict after training #180

Open
SirishNutakki opened this issue Aug 12, 2021 · 4 comments
Open

Errors when trying to predict after training #180

SirishNutakki opened this issue Aug 12, 2021 · 4 comments

Comments

@SirishNutakki
Copy link

We successfully trained a model on an 11gb graphics card, but when trying to run predictions, we ran into a CUDA out of memory error.
Screen Shot 2021-07-29 at 1 04 46 PM

We then tried cropping the images to try to fix this error. We tried predicting with the original model and a new model trained on the cropped images but ran into an error stating that the size of the two tensors in fnet_nn_3d_params.py line 75 don't match.
image

We printed the sizes of the two tensors and found that they are the same size at the point where the error occurs.
image

Do you have any advice on how to fix these issues?

@alxndrkalinin
Copy link

alxndrkalinin commented Aug 24, 2021

Check that your image sizes in X and Y are divisible by 16. You can crop or pad if they're not.

Basic solution: add following code before return statement in the item_from_dataset function (assumes X,Y sizes are even)

    # crop XY to the nearest size divisible by 16
    if signal.shape[2] % 16 != 0:
        signal = signal[:,:,signal.shape[2]%16//2:0-signal.shape[2]%16//2,:]
        target = target[:,:,target.shape[2]%16//2:0-target.shape[2]%16//2,:]
    if signal.shape[3] % 16 != 0:
        signal = signal[:,:,:,signal.shape[3]%16//2:0-signal.shape[3]%16//2]
        target = target[:,:,:,target.shape[3]%16//2:0-target.shape[3]%16//2]

@SirishNutakki
Copy link
Author

Thanks for the help. The solution you suggested fixed the error, but it leads to a different error with the number of channels.
image

@alxndrkalinin
Copy link

What are the sizes of your images at training and at prediction? Fnet also requires the minimum of 32 slices in Z.

@SirishNutakki
Copy link
Author

SirishNutakki commented Sep 2, 2021

We're using the images downloaded from download_and_train.py and cropping them in the x and y dimensions, so they do have at least 32 slices in Z. The model was trained on the original uncropped images and the size of the cropped images are 688x464.

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

2 participants