pytorch FailedPreconditionError:runs不是目录

wlsrxk51  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(181)

我用我收集的自定义数据集制作了自己的GAN,我想使用Tensorboard,它给了我一个错误。我问了ChatGPT,Bard和BingAI,但他们无法修复错误。

from torch.utils.tensorboard import SummaryWriter

writer_fake = SummaryWriter()
writer_real = SummaryWriter()

字符串
我得到这个错误,它创建了一个名为“运行”的新文件夹,但随后引发了错误

---------------------------------------------------------------------------
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


我找了很多,但什么也没找到。

im9ewurl

im9ewurl1#

我遇到了一个类似的问题,并能够解决它。在我的情况下,问题是,有俄语字母的路径中的.ipynb文件(windows用户名是用俄语写的)。只要我把文件移动到一个不同的路径,只有拉丁字母,问题就解决了。

相关问题