-
Notifications
You must be signed in to change notification settings - Fork 68
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
Benchmark VISTA3D #671
Draft
binliunls
wants to merge
2
commits into
Project-MONAI:dev
Choose a base branch
from
binliunls:benchmark_vista3d
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Benchmark VISTA3D #671
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
"output_dtype": "$np.float32", | ||
"output_postfix": "trans", | ||
"separate_folder": true, | ||
"input_dict": "${'image': '/data/Task09_Spleen/imagesTr/spleen_10.nii.gz', 'label_prompt': [3]}", | ||
"sw_batch_size": 10, | ||
"input_dict": "${'image': '/home/liubin/data/trt_2408/dataset/Task09_Spleen/imagesTr/spleen_10.nii.gz'}", | ||
"everything_labels": "$list(set([i+1 for i in range(132)]) - set([2,16,18,20,21,23,24,25,26,27,128,129,130,131,132]))", | ||
"metadata_path": "$@bundle_root + '/configs/metadata.json'", | ||
"metadata": "$json.loads(pathlib.Path(@metadata_path).read_text())", | ||
|
@@ -40,7 +41,6 @@ | |
1.5, | ||
1.5 | ||
], | ||
"sw_batch_size": 1, | ||
"patch_size": [ | ||
128, | ||
128, | ||
|
@@ -105,9 +105,19 @@ | |
"dtype": "$torch.float32" | ||
} | ||
], | ||
"range_preprocessing": { | ||
"_target_": "Range", | ||
"name": "preprocessing", | ||
"recursive": true | ||
}, | ||
"range_postprocessing": { | ||
"_target_": "Range", | ||
"name": "postprocessing", | ||
"recursive": true | ||
}, | ||
"preprocessing": { | ||
"_target_": "Compose", | ||
"transforms": "$@preprocessing_transforms " | ||
"transforms": "$@range_preprocessing(@preprocessing_transforms)" | ||
}, | ||
"dataset": { | ||
"_target_": "Dataset", | ||
|
@@ -128,48 +138,57 @@ | |
"sw_batch_size": "@sw_batch_size", | ||
"use_point_window": "@use_point_window" | ||
}, | ||
"postprocessing_transforms": [ | ||
{ | ||
"_target_": "ToDeviced", | ||
"keys": "pred", | ||
"device": "cpu", | ||
"_disabled_": true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is disabled - why don't we remove this transform from post? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @heyufan1995 could you please answer this one? Thanks |
||
}, | ||
{ | ||
"_target_": "monai.apps.vista3d.transforms.VistaPostTransformd", | ||
"keys": "pred" | ||
}, | ||
{ | ||
"_target_": "Invertd", | ||
"keys": "pred", | ||
"transform": "$copy.deepcopy(@preprocessing)", | ||
"orig_keys": "@image_key", | ||
"nearest_interp": true, | ||
"to_tensor": true | ||
}, | ||
{ | ||
"_target_": "Lambdad", | ||
"func": "$lambda x: torch.nan_to_num(x, nan=255)", | ||
"keys": "pred" | ||
}, | ||
{ | ||
"_target_": "SaveImaged", | ||
"keys": "pred", | ||
"resample": false, | ||
"output_dir": "@output_dir", | ||
"output_ext": "@output_ext", | ||
"output_dtype": "@output_dtype", | ||
"output_postfix": "@output_postfix", | ||
"separate_folder": "@separate_folder" | ||
} | ||
], | ||
"postprocessing": { | ||
"_target_": "Compose", | ||
"transforms": [ | ||
{ | ||
"_target_": "ToDeviced", | ||
"keys": "pred", | ||
"device": "cpu", | ||
"_disabled_": true | ||
}, | ||
{ | ||
"_target_": "monai.apps.vista3d.transforms.VistaPostTransformd", | ||
"keys": "pred" | ||
}, | ||
{ | ||
"_target_": "Invertd", | ||
"keys": "pred", | ||
"transform": "$copy.deepcopy(@preprocessing)", | ||
"orig_keys": "@image_key", | ||
"nearest_interp": true, | ||
"to_tensor": true | ||
}, | ||
{ | ||
"_target_": "Lambdad", | ||
"func": "$lambda x: torch.nan_to_num(x, nan=255)", | ||
"keys": "pred" | ||
}, | ||
{ | ||
"_target_": "SaveImaged", | ||
"keys": "pred", | ||
"resample": false, | ||
"output_dir": "@output_dir", | ||
"output_ext": "@output_ext", | ||
"output_dtype": "@output_dtype", | ||
"output_postfix": "@output_postfix", | ||
"separate_folder": "@separate_folder" | ||
} | ||
] | ||
"transforms": "$@range_postprocessing(@postprocessing_transforms)" | ||
}, | ||
"handlers": [ | ||
{ | ||
"_target_": "StatsHandler", | ||
"iteration_log": false | ||
}, | ||
{ | ||
"_target_": "RangeHandler", | ||
"events": "ITERATION" | ||
}, | ||
{ | ||
"_target_": "RangeHandler", | ||
"events": "BATCH" | ||
} | ||
], | ||
"checkpointloader": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we determine it based on GPU memory size?
torch.cuda.get_device_properties('device').total_memory will give you the total memory. based on total memory and patch size you can come with a simple logic to determine if you want to use batch size 1,2,4,8,10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SachidanandAlle , I am not sure what the
a simple logic to determine if you want to use batch size 1,2,4,8,10
means here. If the patch size is fixed, then GPU memory usage is fixed. Do you suggest to change to a smaller batch size if the GPU memory is not enough? Otherwise I think we should always choose the 14 as the batchsize here.Thanks
Bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on GPU size determine what is the best batch size you can use. if you have enough gpu memory then use higher batch sizes. have you tried running batch size 10 for 16 GB v100? if batch size 10 works for a typical 512x512x256 image then, we are good with default 10 as the batch size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it shall be great if we can modify our sw_inferer logic to determine (we can be little smart here) the required sw_batch size based on the following 3 things.
cc: @Nic-Ma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SachidanandAlle ,
I've updated the benchmark results with more images. According to some results, the latency will reach the best one at a specific batch size. Both increase and decrease will make the latency worse. I think this batch size is a tradeoff betweeen overhead and calculation. When batchsize is small, the overhead will waste too much time. But when batchsize is large, the calculation will waste too much time.
And I also checked the GPU memory this time. I note that for some images even batchsize 1 exceed the 16GB for V100 16GB GPU. You can check the detail in the image shown below. I don't think VISTA3D is a model that suit for GPU memory size less than 16GB. And for acceleration purpose, we may need more GPU memory.
I am trying to benchmark a (512, 512, 256) image. Will update the result later.