DCBIA-OrthoLab / SlicerDentalModelSeg

This extension aims to provide a GUI for a deep-learning automated teeth segmentation tool that we developed at the University of North Carolina in Chapel Hill in collaboration with the University of Michigan in Ann Arbor.
Apache License 2.0
44 stars 10 forks source link

Cannot run without CUDA #13

Open Connor-Bowley opened 2 years ago

Connor-Bowley commented 2 years ago

It would be good to be able to run without CUDA. I got the following error:

CLI execution failed: 

CrownSegmentationcli standard error:

Traceback (most recent call last):
  File "/data/Projects-build/salt-general/SlicerJawSegmentation-build/lib/SlicerSALT-5.1/cli-modules/CrownSegmentationcli.py", line 297, in <module>
    main(sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4]), sys.argv[5],sys.argv[6], sys.argv[7], sys.argv[8])
  File "/data/Projects-build/salt-general/SlicerJawSegmentation-build/lib/SlicerSALT-5.1/cli-modules/CrownSegmentationcli.py", line 145, in main
    model.load_state_dict(torch.load(unet_model))
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 712, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 1046, in _load
    result = unpickler.load()
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 1016, in persistent_load
    load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 1001, in load_tensor
    wrap_storage=restore_location(storage, location),
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 176, in default_restore_location
    result = fn(storage, location)
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 152, in _cuda_deserialize
    device = validate_cuda_device(location)
  File "/home/connor/Projects-build/salt-general/build-5-2/python-install/lib/python3.9/site-packages/torch/serialization.py", line 136, 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.
juanprietob commented 1 year ago

Working on it. The pull request https://github.com/DCBIA-OrthoLab/SlicerDentalModelSeg/pull/22 should address this issue. @HUTIN1 please help test if it works without CUDA now?