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 while running DLMUSE individually on the cluster #9

Open
euroso97 opened this issue Feb 28, 2025 · 1 comment
Open

Error while running DLMUSE individually on the cluster #9

euroso97 opened this issue Feb 28, 2025 · 1 comment

Comments

@euroso97
Copy link
Contributor

Reporting the following errors. I used 'pip install DLMUSE'.

Case #1: Initial run (including the model downloading process)

Renaming dic is saved to /Projects/mask_sample_DLMUSE/renamed_image/renaming.json
Using model folder: /cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/DLMUSE/nnunet_results/Dataset903_Task903_DLMUSEV2/nnUNetTrainer__nnUNetPlans__3d_fullres/
DLMUSE model not found, downloading...

Fetching 15 files:   0%|          | 0/15 [00:00<?, ?it/s]
Fetching 15 files:   7%|| 1/15 [00:00<00:01,  7.81it/s]
Fetching 15 files:  53%|█████▎    | 8/15 [00:00<00:00, 13.08it/s]
Fetching 15 files:  73%|███████▎  | 11/15 [00:02<00:01,  3.40it/s]
Fetching 15 files:  80%|████████  | 12/15 [00:03<00:00,  3.30it/s]
Fetching 15 files: 100%|██████████| 15/15 [00:03<00:00,  4.94it/s]
DLMUSE model has been successfully downloaded!
Running in CUDA mode.
Traceback (most recent call last):
  File "/cbica/home/baikk/.conda/envs/NIB/bin/DLMUSE", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/DLMUSE/__main__.py", line 330, in main
    predictor.initialize_from_trained_model_folder(
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/nnunetv2/inference/predict_from_raw_data.py", line 84, in initialize_from_trained_model_folder
    checkpoint = torch.load(join(model_training_output_dir, f'fold_{f}', checkpoint_name),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, �[1mdo those steps only if you trust the source of the checkpoint�[0m. 
	(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
	(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
	WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default. Please use `torch.serialization.add_safe_globals([scalar])` or the `torch.serialization.safe_globals([scalar])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

Case #2: Second launch (the model was downloaded in the first step, so now skips the downloading and goes straight to running)

Renaming dic is saved to /Projects/renamed_image/renaming.json
Using model folder: /cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/DLMUSE/nnunet_results/Dataset903_Task903_DLMUSEV2/nnUNetTrainer__nnUNetPlans__3d_fullres/
Loading the model...
Running in CUDA mode.
Traceback (most recent call last):
  File "/cbica/home/baikk/.conda/envs/NIB/bin/DLMUSE", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/DLMUSE/__main__.py", line 330, in main
    predictor.initialize_from_trained_model_folder(
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/nnunetv2/inference/predict_from_raw_data.py", line 84, in initialize_from_trained_model_folder
    checkpoint = torch.load(join(model_training_output_dir, f'fold_{f}', checkpoint_name),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cbica/home/baikk/.conda/envs/NIB/lib/python3.12/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, �[1mdo those steps only if you trust the source of the checkpoint�[0m. 
	(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
	(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
	WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default. Please use `torch.serialization.add_safe_globals([scalar])` or the `torch.serialization.safe_globals([scalar])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
@euroso97
Copy link
Contributor Author

Seems to work fine when I used git clone installation method with "pip install -e ."

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

1 participant