Skip to content

Commit

Permalink
upgrade Torch to 2.3.1, upgrade RVC (#341)
Browse files Browse the repository at this point in the history
* add tsconfig to validate bootstrap scripts

* improve default magnet params

* upgrade to torch 2.3.1

* add debug flags

* add hydra-core fix back to installer

* update styletts2

* readme

* fix gradio warnings

* ignore new torch deprecation warnings

* upgrade to new rvc

* upgrade uvr5
  • Loading branch information
rsxdalv authored Jul 13, 2024
1 parent 5e064f6 commit 5ced340
Show file tree
Hide file tree
Showing 39 changed files with 411 additions and 249 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ WORKDIR /app/tts-generation-webui

# Install all requirements
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_audiocraft.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_bark_hubert_quantizer.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_rvc.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_audiocraft.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_styletts2.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_vall_e.txt
RUN pip3 install --no-cache-dir torch==$TORCH_VERSION -r requirements_maha_tts.txt
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ List of models: Bark, MusicGen + AudioGen, Tortoise, RVC, Vocos, Demucs, Seamles

## Changelog

July 13:
* Major upgrade to Torch 2.3.1 and xformers 0.0.27
* All users, including Mac and CPU will now have the same PyTorch version.
* Upgrade CUDA to 11.8
* Force python to be 3.10.11
* Modify installer to allow upgrading Python and Torch without reinstalling (currently major version 2)
* Fix magnet default params for better quality
* Improve installer script checks to avoid bugs
* Update StyleTTS2

July 11:
* Improve Stable Audio generation filenames
* Add force reinstall to torch repair
Expand All @@ -40,6 +50,11 @@ July 1:
* Remove unnecessary conda git reinstall.
* Update to lastest Stable Audio which has mps support (requires newer torch versions).


## June 2024

<details>
<summary>Click to expand</summary>
June 22:
* Add Stable Audio to Gradio.

Expand All @@ -61,6 +76,8 @@ May 9:
May 4:
* Group Changelog by month

</details>

## April 2024


Expand Down
2 changes: 2 additions & 0 deletions installer_scripts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output.log

# Ignore GPU choice
.gpu
.major_version
.python_version
16 changes: 6 additions & 10 deletions installer_scripts/init_app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// import fs from "fs";
// import { $, $$, $sh } from "./js/shell";
// import { initializeApp, repairTorch, setupReactUI } from "./js/initializeApp.mjs";
// import { displayError, displayMessage } from "./js/displayMessage.mjs";
// import { processExit } from "./js/processExit.mjs";
const fs = require("fs");
const { $, $$, $sh } = require("./js/shell");
const { $ } = require("./js/shell");
const { displayError, displayMessage } = require("./js/displayMessage.js");
const { processExit } = require("./js/processExit.js");

Expand All @@ -24,6 +19,8 @@ const updateConda = async () => {
await $("conda update -y -n base -c defaults conda");
};

const DEBUG_ALWAYS_RETURN_UPDATED = false;

const syncRepo = async () => {
if (!fs.existsSync(".git")) {
displayMessage("Linking to tts-generation-webui repository");
Expand All @@ -45,7 +42,7 @@ const syncRepo = async () => {
const newHash = fs.readFileSync(file, "utf8");
if (currentHash === newHash) {
displayMessage("No updates found, skipping...");
return false;
return false || DEBUG_ALWAYS_RETURN_UPDATED;
}
return true;
} catch (error) {
Expand All @@ -65,14 +62,14 @@ async function main() {
// });
// })
// .listen(8080);
const version = "0.0.3";
const version = "0.0.4";
displayMessage("\n\nStarting init app (version: " + version + ")...\n\n");
try {
await checkConda();
// await updateConda();
const isUpdated = await syncRepo();
if (!isUpdated) {
// return;
return;
}
const {
initializeApp,
Expand All @@ -87,7 +84,6 @@ async function main() {
processExit(1);
}
displayMessage("\n\nFinished init app.\n");
// processExit(1);
processExit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion installer_scripts/init_mamba.bat
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ set USERPROFILE=%cd%\installer_files\profile
@rem figure out whether git and conda needs to be installed
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%

set PACKAGES_TO_INSTALL=git python=3.10 nodejs=18.16.1 conda
set PACKAGES_TO_INSTALL=git python=3.10.11 nodejs=18.16.1 conda

@REM if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" set umamba_exists=F
if not exist "temp" mkdir temp
Expand Down
2 changes: 1 addition & 1 deletion installer_scripts/init_mamba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ umamba_exists="F"
# figure out whether git and conda needs to be installed
if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi

PACKAGES_TO_INSTALL="python=3.10 nodejs=18.16.1 conda"
PACKAGES_TO_INSTALL="python=3.10.11 nodejs=18.16.1 conda"

if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi

Expand Down
113 changes: 87 additions & 26 deletions installer_scripts/js/initializeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,67 @@ const { processExit } = require("./processExit.js");
const { menu } = require("./menu.js");
const { $, $$, $sh } = require("./shell.js");

const DEBUG_DRY_RUN = false;

// const torchVersion = $$(`pip show torch | grep Version`);
const torchVersion = "2.0.0";
const torchVersion = "2.3.1";
const cudaVersion = "11.8";

// xformers==0.0.19 # For torch==2.0.0 project plane
// xformers==xformers-0.0.22.post7 # For torch==2.1.0 project plane
const pythonVersion = `3.10.11`;
const pythonPackage = `python=${pythonVersion}`;
const ffmpegPackage = `pytorch::ffmpeg`;
const cudaChannels = [
"",
"pytorch",
`nvidia/label/cuda-${cudaVersion}.0`,
"nvidia",
].join(" -c ");
const cpuChannels = ["", "pytorch"].join(" -c ");

const cudaPackages = `pytorch[version=${torchVersion},build=py3.10_cuda${cudaVersion}*] torchvision torchaudio pytorch-cuda=${cudaVersion} cuda-toolkit ninja`;
const cudaPytorchInstall$ = `conda install -y -k ${ffmpegPackage} ${cudaPackages} ${cudaChannels}`;

const cpuPackages = `pytorch=${torchVersion} torchvision torchaudio cpuonly`;
const pytorchCPUInstall$ = `conda install -y -k ${ffmpegPackage} ${cpuPackages} ${cpuChannels}`;

// console.log(cudaPytorchInstall$);
// console.log(pytorchCPUInstall$);

const ensurePythonVersion = async () => {
try {
displayMessage("Checking python version...");
const version = await getPythonVersion();
if (version !== `Python ${pythonVersion}`) {
displayMessage(`Current python version is """${version}"""`);
displayMessage(`Python version is not ${pythonVersion}. Reinstalling...`);
await $(`conda install -y -k -c conda-forge ${pythonPackage}`);
await $(`conda install -y -k -c conda-forge pip==23.3.2`);
}
} catch (error) {
displayError("Failed to check/install python version");
}

// pytorch::ffmpeg
const cudaPackages =
"pytorch[version=2,build=py3.10_cuda11.7*] torchvision torchaudio pytorch-cuda=11.7 cuda-toolkit ninja ffmpeg -c pytorch -c nvidia/label/cuda-11.7.0 -c nvidia";
const cudaPytorchInstall$ = `conda install -y -k ${cudaPackages}`;
async function getPythonVersion() {
await $sh(`python --version > installer_scripts/.python_version`);
return fs.readFileSync("installer_scripts/.python_version", "utf8").trim();
}
};

const installDependencies = async (gpuchoice) => {
try {
if (gpuchoice === "NVIDIA GPU") {
await $(cudaPytorchInstall$);
} else if (gpuchoice === "Apple M Series Chip" || gpuchoice === "CPU") {
await $(
"conda install -y -k pytorch torchvision torchaudio cpuonly ffmpeg -c pytorch"
);
await $(pytorchCPUInstall$);
} else {
displayMessage("Unsupported or cancelled. Exiting...");
removeGPUChoice();
processExit(1);
}

saveMajorVersion(majorVersion);
await updateDependencies(false);
} catch (error) {
displayError(`Error during installation: ${error.message}`);
Expand All @@ -51,6 +90,8 @@ Select the device (GPU/CPU) you are using to run the application:
);

const gpuFile = "./installer_scripts/.gpu";
const majorVersionFile = "./installer_scripts/.major_version";
const majorVersion = "2";

const saveGPUChoice = (gpuchoice) => {
fs.writeFileSync(gpuFile, gpuchoice.toString());
Expand All @@ -69,12 +110,23 @@ const readGPUChoice = () => {
return -1;
};

const readMajorVersion = () => {
if (fs.existsSync(majorVersionFile)) {
return fs.readFileSync(majorVersionFile, "utf8");
}
return -1;
};

const saveMajorVersion = (majorVersion) => {
fs.writeFileSync(majorVersionFile, majorVersion.toString());
};

const dry_run_flag = DEBUG_DRY_RUN ? "--dry-run " : "";

function tryInstall(requirements, name = "") {
try {
displayMessage(`Installing ${name || requirements} dependencies...`);
// const torchVersion = $$(`pip show torch | grep Version`);
const torchVersion = "2.0.0";
$sh(`pip install ${requirements} torch==${torchVersion}`);
$sh(`pip install ${dry_run_flag}${requirements} torch==${torchVersion}`);
displayMessage(
`Successfully installed ${name || requirements} dependencies`
);
Expand All @@ -96,16 +148,21 @@ async function updateDependencies(optional = true) {
}
}

tryInstall("-r requirements.txt", "Core Packages, Bark, Tortoise");
displayMessage("Updating dependencies...");
// xformers==0.0.19 # For torch==2.0.0 project plane
tryInstall("-r requirements_audiocraft.txt xformers==0.0.19", "Audiocraft");
tryInstall("-r requirements.txt", "Core Packages, Bark, Tortoise");
tryInstall(
"xformers==0.0.27 --index-url https://download.pytorch.org/whl/cu118",
"xformers"
);
tryInstall("-r requirements_bark_hubert_quantizer.txt", "Bark Voice Clone");
tryInstall("-r requirements_rvc.txt", "RVC");
tryInstall("-r requirements_audiocraft.txt", "Audiocraft");
tryInstall("-r requirements_styletts2.txt", "StyleTTS");
tryInstall("-r requirements_vall_e.txt", "Vall-E-X");
tryInstall("-r requirements_maha_tts.txt", "Maha TTS");
tryInstall("-r requirements_stable_audio.txt", "Stable Audio");
// reinstall hydra-core==1.1.0 because of fairseq
tryInstall("hydra-core==1.1.0", "hydra-core fix");
}

const checkIfTorchInstalled = async () => {
Expand All @@ -122,13 +179,20 @@ const checkIfTorchInstalled = async () => {
};

const initializeApp = async () => {
displayMessage("Ensuring that python has the correct version...");
await ensurePythonVersion();
displayMessage("Checking if Torch is installed...");
if (await checkIfTorchInstalled()) {
displayMessage("Torch is already installed. Skipping installation...");
await updateDependencies();
return;
if (readMajorVersion() === majorVersion) {
if (await checkIfTorchInstalled()) {
displayMessage("Torch is already installed. Skipping installation...");
await updateDependencies();
return;
} else {
displayMessage("Torch is not installed. Starting installation...\n");
}
} else {
displayMessage("Major version update detected. Upgrading base environment");
}
displayMessage("Torch is not installed. Starting installation...\n");

if (fs.existsSync(gpuFile)) {
const gpuchoice = readGPUChoice();
Expand Down Expand Up @@ -159,21 +223,18 @@ const checkIfTorchHasCuda = async () => {
};

async function repairTorch() {
// get gpu choice
const choice = readGPUChoice();
if (!checkIfTorchHasCuda() && choice === "NVIDIA GPU") {
const gpuChoice = readGPUChoice();
if (!checkIfTorchHasCuda() && gpuChoice === "NVIDIA GPU") {
displayMessage("Backend is NVIDIA GPU, fixing PyTorch");
try {
await $(`conda install -y -k --force-reinstall ${cudaPackages}`);
} catch (error) {
displayError("Failed to fix torch");
}
} else if (choice === "CPU" || choice === "Apple M Series Chip") {
} else if (gpuChoice === "CPU" || gpuChoice === "Apple M Series Chip") {
displayMessage("Backend is CPU/Apple M Series Chip, fixing PyTorch");
try {
await $(
"conda install -y -k --force-reinstall pytorch torchvision torchaudio cpuonly -c pytorch"
);
await $(`conda install -y -k --force-reinstall ${cpuPackages}`);
} catch (error) {
displayError("Failed to fix torch");
}
Expand Down
72 changes: 72 additions & 0 deletions installer_scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
Loading

0 comments on commit 5ced340

Please sign in to comment.