pytorch実行時にエラー(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.)
Opened this issue · 1 comments
pytorch実行時にエラー(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.)
詳細
game_level: 1
game_time: 180
RANDOM_SEED: 0
IS_MODE :predict_sample
OBSTACLE_HEIGHT: 0
OBSTACLE_PROBABILITY: 0
USER_NAME: bushio
SHAPE_LIST_MAX: 6
BLOCK_NUM_MAX: -1
RESULT_LOG_JSON: /home/ubuntu/tetris_game_autotest/20230301/result/resultlog_bushio.json
TRAIN_YAML: config/default.yaml
PREDICT_WEIGHT: weight/DQN/best_weight.pt
game_level: 1
game_time: 180
RANDOM_SEED: 0
IS_MODE :predict
OBSTACLE_HEIGHT: 0
OBSTACLE_PROBABILITY: 0
USER_NAME: cookie4869
SHAPE_LIST_MAX: 6
BLOCK_NUM_MAX: -1
RESULT_LOG_JSON: /home/ubuntu/tetris_game_autotest/20230301/result/resultlog_cookie4869.json
TRAIN_YAML: config/default.yaml
PREDICT_WEIGHT: outputs/2022-08-31-08-05-53/trained_model/tetris_epoch1701_score189000.pt
Python 3.8.10
CompletedProcess(args='python --version', returncode=0, stderr='')
Python 3.8.10
CompletedProcess(args='python --version', returncode=0, stderr='')
In:1.58% 00:00:02.90 [00:03:00.82] Out:139k [ -===|===- ] Clip:0 model name: DQN
Load weight/DQN/best_weight.pt...
Traceback (most recent call last):
File "game_manager/game_manager.py", line 265, in timerEvent
self.nextMove = BLOCK_CONTROLLER_TRAIN.GetNextMove(nextMove, GameStatus,yaml_file=self.train_yaml,weight=self.predict_weight)
File "/home/ubuntu/tetris_game_autotest/20230301/tetris_dir/tetris_bushio/game_manager/machine_learning/block_controller_train_sample.py", line 501, in GetNextMove
self.set_parameter(yaml_file=yaml_file,predict_weight=weight)
File "/home/ubuntu/tetris_game_autotest/20230301/tetris_dir/tetris_bushio/game_manager/machine_learning/block_controller_train_sample.py", line 111, in set_parameter
self.model = torch.load(predict_weight)
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 789, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 1131, in _load
result = unpickler.load()
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 1101, in persistent_load
load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 1083, in load_tensor
wrap_storage=restore_location(storage, location),
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 215, in default_restore_location
result = fn(storage, location)
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 182, in _cuda_deserialize
device = validate_cuda_device(location)
File "/home/ubuntu/venvtest/lib/python3.8/site-packages/torch/serialization.py", line 166, 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.
原因(推測)
torch.device('cpu') で動いてるところとgpuで動いているところがどちらも存在している
どちらかに統一する必要がある
(全部CPU or GPUで動かす部分は全てgpu(もしgpuが利用可能ならば)で動かすように統一したい)
@seigot Pull request completed! Check it out here #173 🚀
Note: I automatically create a pull request for an unassigned and open issue in order from oldest to newest once a day at 00:00 UTC, as long as you have remaining automation usage. Should you have any questions or wish to change settings or limits, please feel free to contact info@gitauto.ai or invite us to Slack Connect.