mahmoodlab / CLAM

Data-efficient and weakly supervised computational pathology on whole slide images - Nature Biomedical Engineering
http://clam.mahmoodlab.org
GNU General Public License v3.0
975 stars 329 forks source link

Issue running create_heatmaps.py #215

Closed suminwei closed 4 months ago

suminwei commented 7 months ago

Hello, I'm running into the following error when trying to run create_heatmaps.py:

CUDA_VISIBLE_DEVICES=0 python /n/data1/dfci/medicine/beltran/lab/lwei/Software/CLAM_install/CLAM/create_heatmaps.py --config config_template_SARC_KICH.yaml

Traceback (most recent call last): File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/CLAM_install/CLAM/create_heatmaps.py", line 164, in <module> model = initiate_model(model_args, ckpt_path) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/CLAM_install/CLAM/utils/eval_utils.py", line 36, in initiate_model ckpt = torch.load(ckpt_path) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 426, in load return _load(f, map_location, pickle_module, **pickle_load_args) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 613, in _load result = unpickler.load() File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 576, in persistent_load deserialized_objects[root_key] = restore_location(obj, location) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 155, in default_restore_location result = fn(storage, location) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 131, in _cuda_deserialize device = validate_cuda_device(location) File "/n/data1/dfci/medicine/beltran/lab/lwei/Software/anaconda3/envs/clam/lib/python3.7/site-packages/torch/serialization.py", line 115, in validate_cuda_device raise RuntimeError('Attempting to deserialize object on a CUDA ' RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Do you suggest I modify serialization.py to change the settings? Thank you!

suminwei commented 7 months ago

I was able to resolve this, by modifying eval_utils.py

GeorgeBatch commented 5 months ago

@suminwei I think if you are on a CPU-only machine, you should not put CUDA_VISIBLE_DEVICES=0 at all:

python /n/data1/dfci/medicine/beltran/lab/lwei/Software/CLAM_install/CLAM/create_heatmaps.py --config config_template_SARC_KICH.yaml