调用 pytorch enumerate 方法时似乎出现错误。从谷歌搜索错误消息来看,这似乎是我的操作系统 macOS catalina 的问题。有没有我找不到的解决方案和/或有没有使用枚举的替代方法?(我正在运行其他人编写的脚本,并且不熟悉 pytorch 中的 DataLoaders 并且找不到有关 enumerate 方法的太多信息)。这是完整的错误消息:
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Couldn't close file
Traceback (most recent call last):
File "background_analysis.py", line 313, in <module>
validation_classifier(fit_tree, "../events/" + data + "/dataframes/bbbb_SR.h5", data_name=data, method_name=method, region='SR', epochs=15)
File "/Users/Trevor/Desktop/Research/toy4b/python/validation.py", line 18, in validation_classifier
model.runEpoch(print_all_epochs=True, fit_validation=True, data_name=data_name, method_name=method_name, region=region)
File "fvt_scripts/model_train.py", line 1270, in runEpoch
self.validate()
File "fvt_scripts/model_train.py", line 1132, in validate
self.evaluate(self.validation, doROC)
File "fvt_scripts/model_train.py", line 1111, in evaluate
for i, (J, O, D, Q, y, w) in enumerate(results.evalLoader):
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 279, in __iter__
return _MultiProcessingDataLoaderIter(self)
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 746, in __init__
self._try_put_index()
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 861, in _try_put_index
index = self._next_index()
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 339, in _next_index
return next(self._sampler_iter) # may raise StopIteration
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/sampler.py", line 202, in __iter__
if len(batch) == self.batch_size:
File "/Users/Trevor/Desktop/Research/myenv/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
_error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 6750) is killed by signal: Unknown signal: 0.
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Couldn't close file
Abort trap: 6