Repository: Project-MONAI/MONAI
File: monai/apps/nnunet/nnunetv2_runner.py (Python)

Code before:
                know what that is then don't touch it, or at least don't increase it!). DANGER: More
                often than not the number of processes that can be used is limited by the amount of
                RAM available. Image resampling takes up a lot of RAM. MONITOR RAM USAGE AND
                DECREASE -n_proc IF YOUR RAM FILLS UP TOO MUCH! Default: 8 4 8 (=8 processes for 2d, 4
                for 3d_fullres and 8 for 3d_lowres if -c is at its default).
            verbose: Set this to print a lot of stuff. Useful for debugging. Will disable progress bar!
                (Recommended for cluster environments).
        """
        self.extract_fingerprints(fpe, npfp, verify_dataset_integrity, clean, verbose)
        self.plan_experiments(pl, gpu_memory_target, preprocessor_name, overwrite_target_spacing, overwrite_plans_name)

        if not no_pp:
            self.preprocess(c, n_proc, overwrite_plans_name, verbose)

    def train_single_model(self, config: Any, fold: int, gpu_id: tuple | list | int = 0, **kwargs: Any) -> None:
        """
        Run the training on a single GPU with one specified configuration provided.
        Note: this will override the environment variable `CUDA_VISIBLE_DEVICES`.

        Args:
            config: configuration that should be trained. Examples: "2d", "3d_fullres", "3d_lowres".
            fold: fold of the 5-fold cross-validation. Should be an int between 0 and 4.
            gpu_id: an integer to select the device to use, or a tuple/list of GPU device indices used for multi-GPU
                training (e.g., (0,1)). Default: 0.
            kwargs: this optional parameter allows you to specify additional arguments in
                ``nnunetv2.run.run_training.run_training``. Currently supported args are
                - p: custom plans identifier. Default: "nnUNetPlans".
                - pretrained_weights: path to nnU-Net checkpoint file to be used as pretrained model. Will only be
                    used when actually training. Beta. Use with caution. Default: False.
                - use_compressed: True to use compressed data for training. Reading compressed data is much
                    more CPU and (potentially) RAM intensive and should only be used if you know what you are
                    doing. Default: False.
                - c: continue training from latest checkpoint. Default: False.
                - val: True to run the validation only. Requires training to have finished.
                    Default: False.
                - disable_checkpointing: True to disable checkpointing. Ideal for testing things out and you
                    don't want to flood your hard drive with checkpoints. Default: False.
        """
        if "num_gpus" in kwargs:
            kwargs.pop("num_gpus")
            logger.warning("please use gpu_id to set the GPUs to use")

        if "tr" in kwargs:
            kwargs.pop("tr")
            logger.warning("please specify the `trainer_class_name` in the __init__ of `nnUNetV2Runner`.")

        if "npz" in kwargs:
            kwargs.pop("npz")
            logger.warning("please specify the `export_validation_probabilities` in the __init__ of `nnUNetV2Runner`.")

        cmd = self.train_single_model_command(config, fold, gpu_id, kwargs)

Review comment (suggestion):
Please change ``nnunetv2.run.run_training.run_training`` to  ``nnunetv2.run.run_training.run_training_entry``. Thanks.

Code after:
                know what that is then don't touch it, or at least don't increase it!). DANGER: More
                often than not the number of processes that can be used is limited by the amount of
                RAM available. Image resampling takes up a lot of RAM. MONITOR RAM USAGE AND
                DECREASE -n_proc IF YOUR RAM FILLS UP TOO MUCH! Default: 8 4 8 (=8 processes for 2d, 4
                for 3d_fullres and 8 for 3d_lowres if -c is at its default).
            verbose: Set this to print a lot of stuff. Useful for debugging. Will disable progress bar!
                (Recommended for cluster environments).
        """
        self.extract_fingerprints(fpe, npfp, verify_dataset_integrity, clean, verbose)
        self.plan_experiments(pl, gpu_memory_target, preprocessor_name, overwrite_target_spacing, overwrite_plans_name)

        if not no_pp:
            self.preprocess(c, n_proc, overwrite_plans_name, verbose)

    def train_single_model(self, config: Any, fold: int, gpu_id: tuple | list | int = 0, **kwargs: Any) -> None:
        """
        Run the training on a single GPU with one specified configuration provided.
        Note: this will override the environment variable `CUDA_VISIBLE_DEVICES`.

        Args:
            config: configuration that should be trained. Examples: "2d", "3d_fullres", "3d_lowres".
            fold: fold of the 5-fold cross-validation. Should be an int between 0 and 4.
            gpu_id: an integer to select the device to use, or a tuple/list of GPU device indices used for multi-GPU
                training (e.g., (0,1)). Default: 0.
            kwargs: this optional parameter allows you to specify additional arguments in
                ``nnunetv2.run.run_training.run_training_entry``.

                Currently supported args are:

                - p: custom plans identifier. Default: "nnUNetPlans".
                - pretrained_weights: path to nnU-Net checkpoint file to be used as pretrained model. Will only be
                    used when actually training. Beta. Use with caution. Default: False.
                - use_compressed: True to use compressed data for training. Reading compressed data is much
                    more CPU and (potentially) RAM intensive and should only be used if you know what you are
                    doing. Default: False.
                - c: continue training from latest checkpoint. Default: False.
                - val: True to run the validation only. Requires training to have finished.
                    Default: False.
                - disable_checkpointing: True to disable checkpointing. Ideal for testing things out and you
                    don't want to flood your hard drive with checkpoints. Default: False.
        """
        if "num_gpus" in kwargs:
            kwargs.pop("num_gpus")
            logger.warning("please use gpu_id to set the GPUs to use")

        if "tr" in kwargs:
            kwargs.pop("tr")
            logger.warning("please specify the `trainer_class_name` in the __init__ of `nnUNetV2Runner`.")

        if "npz" in kwargs:
            kwargs.pop("npz")