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

Bundles Update #1493

Merged
merged 31 commits into from
Sep 19, 2023
Merged

Bundles Update #1493

merged 31 commits into from
Sep 19, 2023

Conversation

ericspod
Copy link
Member

@ericspod ericspod commented Aug 24, 2023

Fixes #1457, #1452.

Description

This adds tutorials going through the process of creating bundles in their entirety.

Notebooks to add:

  • Very simple intro to bundles and the file structure
  • Simple network bundle that actually does something with training
  • Bundle wrapping pre-existing code and network definitions which would cover non-MONAI code
  • Bundle wrapping non-Pytorch code, maybe?

Checks

  • Avoid including large-size files in the PR.
  • Clean up long text outputs from code cells in the notebook.
  • For security purposes, please check the contents and remove any sensitive info such as user names and private key.
  • Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the ./figure folder
  • Notebook runs automatically ./runner.sh -t <path to .ipynb file>

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

pre-commit-ci bot and others added 3 commits August 24, 2023 23:50
DCO Remediation Commit for Eric Kerfoot <[email protected]>

I, Eric Kerfoot <[email protected]>, hereby add my Signed-off-by to this commit: db2f488
I, Eric Kerfoot <[email protected]>, hereby add my Signed-off-by to this commit: 04d581f
I, Eric Kerfoot <[email protected]>, hereby add my Signed-off-by to this commit: ba19596
I, Eric Kerfoot <[email protected]>, hereby add my Signed-off-by to this commit: 54583ba

Signed-off-by: Eric Kerfoot <[email protected]>
@vikashg vikashg self-assigned this Aug 25, 2023
ericspod and others added 8 commits August 30, 2023 17:02
@ericspod ericspod marked this pull request as ready for review September 7, 2023 16:48
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, the tutorials look nice, cc @mingxin-zheng @Nic-Ma is it possible to skip the cell format requirements? I feel the format is defined primarily for pure python notebooks, in this PR, many cells demonstrate CLI features.

@ericspod
Copy link
Member Author

ericspod commented Sep 8, 2023

The examples use the command tree to show the files in a bundle, is this not present in the CI environment? That might explain the errors with the notebook tests.

ericspod and others added 12 commits September 8, 2023 13:16
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>

I had to set MKL_SERVICE_FORCE_INTEL=1 to get the tests to run, maybe this is an issue on the CI system as well.
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
@ericspod
Copy link
Member Author

I had to mangle the third notebook to get an output about the command line error that was encountered. The command fails with:

Traceback (most recent call last):
...
  File "/opt/conda/lib/python3.8/site-packages/torch/cuda/__init__.py", line 247, in _lazy_init
    torch._C._cuda_init()
RuntimeError: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org/ to install a PyTorch version that has been compiled with your version of the CUDA driver.

The top line of nvidia-smi for the containing running the tests is Driver Version: 418.126.02 CUDA Version: 11.6 however when I run the same image locally I get Driver Version: 530.30.02 CUDA Version: 12.1.

@wyli
Copy link
Contributor

wyli commented Sep 13, 2023

thanks, let me try to ask about upgrading the driver version. also is it possible to remove the related component that is causing the issue?

@ericspod
Copy link
Member Author

I think the component is the network being moved onto CUDA so I could just train in software but that's not demonstrating proper practice in a clear way. The network is just densenet121. I would have thought this issue would come up elsewhere but it may be related to spawning a subprocess in notebook 3 to train.

Copy link
Contributor

@vikashg vikashg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @ericspod. Thanks.

@vikashg
Copy link
Contributor

vikashg commented Sep 13, 2023

As I am working through the examples I got this error

(monai-test) gupta@DIGI1036734:~/disk/Tools/CodeReview/monai_bundle$ python -m monai.bundle run train     --bundle_root "$BUNDLE"     --logging_file "$BUNDLE/configs/logging.conf"     --meta_file "$BUNDLE/configs/metadata.json"     --config_file "['$BUNDLE/configs/common.yaml','$BUNDLE/configs/train.yaml']"     --max_epochs 2 
2023-09-13 10:55:39,642 - INFO - --- input summary of monai.bundle.scripts.run ---
2023-09-13 10:55:39,642 - INFO - > run_id: 'train'
2023-09-13 10:55:39,642 - INFO - > meta_file: './MedNISTClassifier_v2/configs/metadata.json'
2023-09-13 10:55:39,642 - INFO - > config_file: ['./MedNISTClassifier_v2/configs/common.yaml',
 './MedNISTClassifier_v2/configs/train.yaml']
2023-09-13 10:55:39,642 - INFO - > logging_file: './MedNISTClassifier_v2/configs/logging.conf'
2023-09-13 10:55:39,642 - INFO - > bundle_root: './MedNISTClassifier_v2'
2023-09-13 10:55:39,642 - INFO - > max_epochs: 2
2023-09-13 10:55:39,642 - INFO - ---


2023-09-13 10:55:39,643 - INFO - Setting logging properties based on config: ./MedNISTClassifier_v2/configs/logging.conf.
Traceback (most recent call last):
  File "/home/gupta/miniconda3/envs/monai-test/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/gupta/miniconda3/envs/monai-test/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/__main__.py", line 30, in <module>
    fire.Fire()
  File "/home/gupta/miniconda3/envs/monai-test/lib/python3.10/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/gupta/miniconda3/envs/monai-test/lib/python3.10/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/gupta/miniconda3/envs/monai-test/lib/python3.10/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/scripts.py", line 684, in run
    workflow = ConfigWorkflow(
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/workflows.py", line 221, in __init__
    self.parser.read_config(f=config_file)
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/config_parser.py", line 320, in read_config
    content.update(self.load_config_files(f, **kwargs))
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/config_parser.py", line 424, in load_config_files
    for k, v in (cls.load_config_file(i, **kwargs)).items():
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/bundle/config_parser.py", line 405, in load_config_file
    return yaml.load(f, CheckKeyDuplicatesYamlLoader, **kwargs)  # type: ignore[no-any-return]
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/utils/module.py", line 436, in __getattr__
    raise self._exception
  File "/home/gupta/disk/Tools/CodeReview/MONAI/monai/utils/module.py", line 395, in optional_import
    pkg = __import__(module)  # top level module
monai.utils.module.OptionalImportError: import yaml (No module named 'yaml').

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

I installed yaml using conda install yaml but the error persists.

@ericspod
Copy link
Member Author

The bundles need fire and yaml to run (those using JSON only need fire). I could put that in the first cell of the notebooks like other notebooks do though the requirements are for the programs being run and not the notebook itself.

@vikashg
Copy link
Contributor

vikashg commented Sep 13, 2023

Ya I have both fire and yaml installed. Let me try again

@ericspod
Copy link
Member Author

The package is pyyaml.

@vikashg
Copy link
Contributor

vikashg commented Sep 13, 2023

Its working now. Thanks

Copy link
Contributor

@vikashg vikashg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericspod ericspod enabled auto-merge (squash) September 19, 2023 15:45
@ericspod ericspod merged commit 0b2638b into Project-MONAI:main Sep 19, 2023
6 checks passed
@ericspod ericspod deleted the bundles_update branch September 19, 2023 16:10
boneseva pushed a commit to boneseva/MONAI-tutorials that referenced this pull request Apr 21, 2024
Fixes Project-MONAI#1457, Project-MONAI#1452.

### Description
This adds tutorials going through the process of creating bundles in
their entirety.

Notebooks to add:
- [x] Very simple intro to bundles and the file structure
- [x] Simple network bundle that actually does something with training
- [x] Bundle wrapping pre-existing code and network definitions which
would cover non-MONAI code
- [ ] Bundle wrapping non-Pytorch code, maybe?

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Avoid including large-size files in the PR.
- [x] Clean up long text outputs from code cells in the notebook.
- [x] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [x] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Eric Kerfoot <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Update Tutorials with clearer simpler examples and step-by-step introduction to concepts
4 participants