Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised: FileExistsError: [WinError 183] Cannot create a file when that file already exists #6

Open
zer0int opened this issue Dec 18, 2024 · 2 comments

Comments

@zer0int
Copy link
Owner

zer0int commented Dec 18, 2024

Just gonna open an issue on myself as I assume people will be most likely to see it here. =)
If you get this error, it has nothing to do with my code / node. It's an issue with PyTorch. To fix it:

In <your-Python>\site-packages\torch\_inductor\codecache.py find def write_atomic, edit it like so (last 3 lines below):

def write_atomic(
    path_: str,
    content: Union[str, bytes],
    make_dirs: bool = False,
    encode_utf_8: bool = False,
) -> None:
    # Write into temporary file first to avoid conflicts between threads
    # Avoid using a named temporary file, as those have restricted permissions
    assert isinstance(
        content, (str, bytes)
    ), "Only strings and byte arrays can be saved in the cache"
    path = Path(path_)
    if make_dirs:
        path.parent.mkdir(parents=True, exist_ok=True)
    tmp_path = path.parent / f".{os.getpid()}.{threading.get_ident()}.tmp"
    write_mode = "w" if isinstance(content, str) else "wb"
    with tmp_path.open(write_mode, encoding="utf-8" if encode_utf_8 else None) as f:
        f.write(content)
    #tmp_path.rename(path) # comment this out, and add the following two lines instead:
    shutil.copy2(src=tmp_path, dst=path)
    os.remove(tmp_path)

Seen here

@Kahdeg-15520487
Copy link

what do you mean by " uncomment this ", did you meant " comment this " ?

@zer0int
Copy link
Owner Author

zer0int commented Dec 20, 2024

@Kahdeg-15520487
Oops. Yes, thank you - fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants