keep-loving-pythonのブログ

Pythonを愛し続けたいです(Pythonが流行っている限りですが。。。)

解決策。BrokenPipeError: [Errno 32] Broken pipe。。。The "freeze_support()" line can be omitted。。。

解決策。BrokenPipeError: [Errno 32] Broken pipe。。。The "freeze_support()" line can be omitted。。。

エラー

環境

windows10
python3.7

エラー

BrokenPipeError: [Errno 32] Broken pipe
        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
    ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

解決策

一般的な解決策

main()みたいな関数に処理を入れ込むやり方。

解決策

このエラーの発生を逃げる方法。<--お薦め。

train_dataloader = DataLoader(train_dataset, num_workers=4, batch_size=BATCH_SIZE, shuffle=True)

の num_workers=4
を消す

train_dataloader = DataLoader(train_dataset, batch_size=BATCH_SIZE, shuffle=True)

コメント

なんでも結構。一言でも結構。コメント欲しいな。。。。