有时在运行 pytorch 代码时我会收到这样的错误
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/olha/arabidopsis_genomes/script_test_model_gradients_chromosome.py", line 97, in process_batch
model = torch.load(os.path.join(base_directory, model_folder, 'model.pt'))
File "/home/olha/.local/lib/python3.6/site-packages/torch/serialization.py", line 367, in load
return _load(f, map_location, pickle_module)
File "/home/olha/.local/lib/python3.6/site-packages/torch/serialization.py", line 538, in _load
result = unpickler.load()
File "/home/olha/.local/lib/python3.6/site-packages/torch/serialization.py", line 504, in persistent_load
data_type(size), location)
File "/home/olha/.local/lib/python3.6/site-packages/torch/serialization.py", line 113, in default_restore_location
result = fn(storage, location)
File "/home/olha/.local/lib/python3.6/site-packages/torch/serialization.py", line 95, in _cuda_deserialize
return obj.cuda(device)
File "/home/olha/.local/lib/python3.6/site-packages/torch/_utils.py", line 68, in _cuda
with torch.cuda.device(device):
File "/home/olha/.local/lib/python3.6/site-packages/torch/cuda/__init__.py", line 229, in __enter__
_lazy_init()
File "/home/olha/.local/lib/python3.6/site-packages/torch/cuda/__init__.py", line 162, in _lazy_init
torch._C._cuda_init()
RuntimeError: generic_type: cannot initialize type "_CudaDeviceProperties": an object with that name is already defined
我无法弄清楚到底是什么导致了错误,也许它以某种方式与线程有关。文档、问题或论坛中没有提及此行为。我能找到的唯一提及该错误的资源是 pybind 中的以下问题:
我正在使用 pytorch 1.0.0 和 CUDA 10