Closed haohlin closed 4 years ago
have you tried model.load_state_dict(torch.load(model_path, map_location='cpu)) in /home/Dev/3D-SIS/lib/nets/enet.py line 699, in create_enet_for_3d as suggested by pytorch.
Also you need to set some parameters as suggested by https://github.com/Sekunde/3D-SIS/issues/19#issuecomment-592370899
I followed suggestions by @mcfrain. I'm still required to use CUDA and an Nvidia GPU:
Traceback (most recent call last):
File "main.py", line 84, in
as i said on #19 , i finally do infer on a pc with a gpu. and i suggest you run the program on a pc with a nvidia gpu, and you also need to install proper nvidia driver with cuda and cudnn.
@haohlin the code is originally designed for the machine that has GPU. The CPU mode is just for some very big scenes that you may not have enough GPU memory. However, if you really want it to run on a CPU machine that without GPU driver, you have to modify some code.
E.g. File "/home/Dev/3D-SIS/lib/utils/timer.py", line 14, in tic torch.cuda.synchronize(), here it invokes CUDA, but you don't have it, you can try to comment out this line, but there are multiple occurrences you need to change.
Thank you both @mcfrain @Sekunde for the help!
I created a docker image and hope to run the example on a Mac on CPU. When I run "python main.py --cfg ScanNet/example --step 1205541 --output_dir example_result/scannet_benchmark_checkpoint --mode benchmark --gpu 0", I get the following error:
Traceback (most recent call last): File "main.py", line 84, in
benchmark(args)
File "/home/Dev/3D-SIS/lib/model/trainval.py", line 70, in benchmark
net.init_modules()
File "/home/Dev/3D-SIS/lib/nets/network.py", line 64, in init_modules
self.image_enet_fixed, self.image_enet_trainable, self.image_enet_classification = enet.create_enet_for_3d(cfg.NUM_2D_CLASSES, cfg.PRETRAINED_ENET_PATH, cfg.NUM_CLASSES)
File "/home/Dev/3D-SIS/lib/nets/enet.py", line 699, in create_enet_for_3d
model.load_state_dict(torch.load(model_path))
File "/home/Applications/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 358, in load
return _load(f, map_location, pickle_module)
File "/home/Applications/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 542, in _load
result = unpickler.load()
File "/home/Applications/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 508, in persistent_load
data_type(size), location)
File "/home/Applications/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 104, in default_restore_location
result = fn(storage, location)
File "/home/Applications/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 75, in _cuda_deserialize
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='cpu' to map your storages to the CPU.
Is it possible to perform inference on CPU at all? I don't see the environment variable CUDA_VISIBLE_DEVICES used anywhere.
Thank you