PyTorch uses tensorboard to show the network operation, but occasionally encounters Segmentation fault errors when using SummaryWriter.
Using Python3's faulthandler, you can locate the wrong line of code. There are two specific operations as follows:
(1) Write faulthandler in the code
import faulthandler # Add the following enable code directly after import() # Write your code normally later
(2) Enable it directly through the command line, add the -X faulthandler parameter at runtime:
python -X faulthandler your_script.py
Error code:
import xxx from import SummaryWriter import yyy log_dir = './run_logs' = SummaryWriter(log_dir)
The error is reported as follows:
File "/opt/conda/lib/python3.7/site-packages/tensorboard/compat/__init__.py", line 45 in tf
File "/opt/conda/lib/python3.7/site-packages/tensorboard/", line 50 in load_once
File "/opt/conda/lib/python3.7/site-packages/tensorboard/", line 97 in wrapper
File "/opt/conda/lib/python3.7/site-packages/tensorboard/", line 65 in __getattr__
File "/opt/conda/lib/python3.7/site-packages/tensorboard/summary/writer/event_file_writer.py", line 72 in __init__
File "/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/",line 66 in __init__
File "/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/",line 256 in _get_file_writer
File "/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/", line 225 in __init__
After querying, it was found that it is very likely that the order of the import SummaryWriter is caused by the problem. Reference link:[TensorBoard] The different order of import SummaryWriter may cause Segmentation fault
Before adjusting the sequence from import SummaryWriter, you can successfully transmit and instantiate the package.
import xxx from import SummaryWriter import yyy
Change to
from import SummaryWriter import xxx import yyy
This is the article about the SummaryWriter error reported by PyTorch using tensorboard. This is all about this article. For more related contents of the SummaryWriter error reported by PyTorch, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!