Giter Site home page Giter Site logo

Comments (5)

Ma5onic avatar Ma5onic commented on June 16, 2024 3

The error message: (PermissionError: [WinError 32] The process cannot access the file because it is being used by another process) indicates that some process is still using a file or directory in the folder you're trying to remove with shutil.rmtree().

This is because stemgen is using os.chdir(os.path.join(OUTPUT_PATH, FILE_NAME)) to change the current working directory. If the Python process (or any other running process) is in the directory you're trying to delete, you'll get a permission error. Before removing the directory, you should change back to some other directory.

I made a pull request (#39) with the following changes to the cleanup process:
Bug Fix:

  • Move out of the Target Directory to be cleaned: Before attempting to remove the directory, I changed the current working directory to OUTPUT_PATH to ensure we are not inside the directory we're trying to delete.
    Minor Improvements
  • Path Handling: Improved the way paths are constructed using os.path.join() consistently instead of a mix of string concatenation and joining. This ensures paths are constructed in a platform-independent manner.
  • Error Handling: Added a try-except block around the shutil.rmtree() call. If a PermissionError occurs, a message is printed indicating the directory might still be in use. This provides a clearer error message and ensures the script doesn't crash due to this specific error.
  • Checking for Stem File: Modified the path for checking and renaming the stem file to ensure it's constructed correctly.

I also added the following improvement for windows users with a GPU:

  • Automatic GPU Detection: Script now does a check to see if CUDA is available. If so, it will use the GPU by default (can be overridden by using the -d/--device flag).
    If no CUDA support is detected, the script will use the CPU instead.

from stemgen.

axeldelafosse avatar axeldelafosse commented on June 16, 2024

Thank you for the report! It is a known (and annoying) issue.

I'm not familiar enough with Windows to understand and fix this quickly, I need to dig. PRs are welcomed! This is a good first issue, if you ever want to try to fix it :)

from stemgen.

awesomer avatar awesomer commented on June 16, 2024

FWIW, Demucs without any -d flag defaults to CUDA-if-available-otherwise-CPU.

from stemgen.

Ma5onic avatar Ma5onic commented on June 16, 2024

@awesomer, yes but there isn't a way of doing that without changing the code because "cpu" is set as the default value in argparse. So if I omit the -d flag, stemgen defaults back to -d cpu

from stemgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.