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

safe_open handle out of scope issue. #574

Open
1 of 2 tasks
diaoenmao opened this issue Feb 14, 2025 · 0 comments
Open
1 of 2 tasks

safe_open handle out of scope issue. #574

diaoenmao opened this issue Feb 14, 2025 · 0 comments

Comments

@diaoenmao
Copy link

diaoenmao commented Feb 14, 2025

System Info

I encounter a similar issue of #164. I try to remove the storage from drive after I loaded. It will give me a permission error on windows unless I add a del to delete the reference to the memory.

tensor = load_tensor(path)[name]
del tensor
os.remove(path) # will work, without del tensor won't work

If I use that tensor somewhere else, deleting the original pointer won't help. It seems like as long as the loaded memory is allocated, the original file on the drive cannot be modified (deleted or overwritten). I believe this should be mentioned somewhere in the documentation.

tensor = load_tensor(path)[name]
a = nn.Parameter(tensor)
del tensor
os.remove(path) # won't work

Information

  • The official example scripts
  • My own modified scripts

Reproduction

tensor = load_tensor(path)[name]
del tensor
os.remove(path) # will work, without del tensor won't work
tensor = load_tensor(path)[name]
a = nn.Parameter(tensor)
del tensor
os.remove(path) # won't work

Expected behavior

Discussion on documentation

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

1 participant