Issue
I made my own GAN with custom dataset that I collected, I wanted to use Tensorboard, It gives me an error.I asked ChatGPT,Bard and BingAI but they couldn't fix the error.
from torch.utils.tensorboard import SummaryWriter
writer_fake = SummaryWriter()
writer_real = SummaryWriter()
I get this error, it creates a new folder named "run", but then raises the error
---------------------------------------------------------------------------
FailedPreconditionError Traceback (most recent call last)
Cell In[28], line 14
9 # os.makedirs("runs/Images/fake")
10 # os.makedirs("runs/Images/real")
11
12 # Initialize SummaryWriter
13 writer_fake = SummaryWriter()
---> 14 writer_real = SummaryWriter()
File ~\pytorch\MLvenv\Lib\site-packages\torch\utils\tensorboard\writer.py:247, in SummaryWriter.__init__(self, log_dir, comment, purge_step, max_queue, flush_secs, filename_suffix)
244 # Initialize the file writers, but they can be cleared out on close
245 # and recreated later as needed.
246 self.file_writer = self.all_writers = None
--> 247 self._get_file_writer()
249 # Create default bins for histograms, see generate_testdata.py in tensorflow/tensorboard
250 v = 1e-12
File ~\pytorch\MLvenv\Lib\site-packages\torch\utils\tensorboard\writer.py:277, in SummaryWriter._get_file_writer(self)
275 """Returns the default FileWriter instance. Recreates it if closed."""
276 if self.all_writers is None or self.file_writer is None:
--> 277 self.file_writer = FileWriter(
278 self.log_dir, self.max_queue, self.flush_secs, self.filename_suffix
279 )
280 self.all_writers = {self.file_writer.get_logdir(): self.file_writer}
281 if self.purge_step is not None:
File ~\pytorch\MLvenv\Lib\site-packages\torch\utils\tensorboard\writer.py:76, in FileWriter.__init__(self, log_dir, max_queue, flush_secs, filename_suffix)
71 # Sometimes PosixPath is passed in and we need to coerce it to
72 # a string in all cases
73 # TODO: See if we can remove this in the future if we are
74 # actually the ones passing in a PosixPath
75 log_dir = str(log_dir)
---> 76 self.event_writer = EventFileWriter(
77 log_dir, max_queue, flush_secs, filename_suffix
78 )
File ~\pytorch\MLvenv\Lib\site-packages\tensorboard\summary\writer\event_file_writer.py:72, in EventFileWriter.__init__(self, logdir, max_queue_size, flush_secs, filename_suffix)
57 """Creates a `EventFileWriter` and an event file to write to.
58
59 On construction the summary writer creates a new event file in `logdir`.
(...)
69 pending events and summaries to disk.
70 """
71 self._logdir = logdir
---> 72 tf.io.gfile.makedirs(logdir)
73 self._file_name = (
74 os.path.join(
75 logdir,
(...)
84 + filename_suffix
85 ) # noqa E128
86 self._general_file_writer = tf.io.gfile.GFile(self._file_name, "wb")
File ~\pytorch\MLvenv\Lib\site-packages\tensorflow\python\lib\io\file_io.py:513, in recursive_create_dir_v2(path)
501 @tf_export("io.gfile.makedirs")
502 def recursive_create_dir_v2(path):
503 """Creates a directory and all parent/intermediate directories.
504
505 It succeeds if path already exists and is writable.
(...)
511 errors.OpError: If the operation fails.
512 """
--> 513 _pywrap_file_io.RecursivelyCreateDir(compat.path_to_bytes(path))
FailedPreconditionError: runs is not a directory
I searched a lot but couldn't find anything.
Solution
II just had a similar problem and was able to solve it. In my case the problem was that there were russian letters in the path of the .ipynb file (windows username is written in russian). As soon as I moved the file to a different path with only latin letters, the problem was solved.
Answered By - XaPoHbomj
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.