Repository: oobabooga/text-generation-webui

Issue:
I start the start_windows.bat and it doesn't work.
### Describe the bug

Downloading Miniconda from https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe to C:\Users\alias\Documents\obabo\text-generation-webui\installer_files\miniconda_installer.exe
Ya existe el subdirectorio o el archivo C:\Users\alias\Documents\obabo\text-generation-webui\installer_files.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - La función de revocación no puede comprobar la revocación para el certificado.

Miniconda failed to download.
Presione una tecla para continuar . . .

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

i followed this tutorial on youtube https://www.youtube.com/watch?v=C-7jGYOGvy4&t=1028s

I tried to solve it with the help of gpt chat but it didn't work.

### Screenshot

_No response_

### Logs

```shell
Downloading Miniconda from https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe to C:\Users\alias\Documents\obabo\text-generation-webui\installer_files\miniconda_installer.exe
Ya existe el subdirectorio o el archivo C:\Users\alias\Documents\obabo\text-generation-webui\installer_files.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - La función de revocación no puede comprobar la revocación para el certificado.

Miniconda failed to download.
Presione una tecla para continuar . . .
```


### System Info

```shell
windows 11
only cpu
intel core i5
8 ram
```



Discussion:

Resolving patch:
diff --git a/modules/extensions.py b/modules/extensions.py
--- a/modules/extensions.py
+++ b/modules/extensions.py
@@ -36,7 +36,7 @@ def load_extensions():
                 try:
                     extension = importlib.import_module(f"extensions.{name}.script")
                 except ModuleNotFoundError:
-                    logger.error(f"Could not import the requirements for '{name}'. Make sure to install the requirements for the extension.\n\nLinux / Mac:\n\npip install -r extensions/{name}/requirements.txt --upgrade\n\nWindows:\n\npip install -r extensions\\{name}\\requirements.txt --upgrade\n\nIf you used the one-click installer, paste the command above in the terminal window opened after launching the cmd script for your OS.")
+                    logger.error(f"Could not import the requirements for '{name}'. Make sure to install the requirements for the extension.\n\n* To install requirements for all available extensions, launch the\n  update_wizard script for your OS and choose the B option.\n\n* To install the requirements for this extension alone, launch the\n  cmd script for your OS and paste the following command in the\n  terminal window that appears:\n\nLinux / Mac:\n\npip install -r extensions/{name}/requirements.txt --upgrade\n\nWindows:\n\npip install -r extensions\\{name}\\requirements.txt --upgrade\n")
                     raise
 
                 # Only run setup() and apply settings from settings.yaml once
diff --git a/one_click.py b/one_click.py
--- a/one_click.py
+++ b/one_click.py
@@ -9,14 +9,21 @@
 import subprocess
 import sys
 
-script_dir = os.getcwd()
-conda_env_path = os.path.join(script_dir, "installer_files", "env")
-
 # Remove the '# ' from the following lines as needed for your AMD GPU on Linux
 # os.environ["ROCM_PATH"] = '/opt/rocm'
 # os.environ["HSA_OVERRIDE_GFX_VERSION"] = '10.3.0'
 # os.environ["HCC_AMDGPU_TARGET"] = 'gfx1030'
 
+
+# Define the required PyTorch version
+TORCH_VERSION = "2.2.1"
+TORCHVISION_VERSION = "0.17.1"
+TORCHAUDIO_VERSION = "2.2.1"
+
+# Environment
+script_dir = os.getcwd()
+conda_env_path = os.path.join(script_dir, "installer_files", "env")
+
 # Command-line flags
 cmd_flags_path = os.path.join(script_dir, "CMD_FLAGS.txt")
 if os.path.exists(cmd_flags_path):
@@ -25,7 +32,7 @@
 else:
     CMD_FLAGS = ''
 
-flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
+flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update-wizard'])} {CMD_FLAGS}"
 
 
 def signal_handler(sig, frame):
@@ -86,13 +93,42 @@ def torch_version():
 
     if site_packages_path:
         torch_version_file = open(os.path.join(site_packages_path, 'torch', 'version.py')).read().splitlines()
-        torver = [line for line in torch_version_file if '__version__' in line][0].split('__version__ = ')[1].strip("'")
+        torver = [line for line in torch_version_file if line.startswith('__version__')][0].split('__version__ = ')[1].strip("'")
     else:
         from torch import __version__ as torver
 
     return torver
 
 
+def update_pytorch():
+    print_big_message("Checking for PyTorch updates")
+
+    torver = torch_version()
+    is_cuda = '+cu' in torver
+    is_cuda118 = '+cu118' in torver  # 2.1.0+cu118
+    is_rocm = '+rocm' in torver  # 2.0.1+rocm5.4.2
+    is_intel = '+cxx11' in torver  # 2.0.1a0+cxx11.abi
+    is_cpu = '+cpu' in torver  # 2.0.1+cpu
+
+    install_pytorch = f"python -m pip install --upgrade torch=={TORCH_VERSION} torchvision=={TORCHVISION_VERSION} torchaudio=={TORCHAUDIO_VERSION} "
+
+    if is_cuda118:
+        install_pytorch += "--index-url https://download.pytorch.org/whl/cu118"
+    elif is_cuda:
+        install_pytorch += "--index-url https://download.pytorch.org/whl/cu121"
+    elif is_rocm:
+        install_pytorch += "--index-url https://download.pytorch.org/whl/rocm5.6"
+    elif is_cpu:
+        install_pytorch += "--index-url https://download.pytorch.org/whl/cpu"
+    elif is_intel:
+        if is_linux():
+            install_pytorch = "python -m pip install --upgrade torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/"
+        else:
+            install_pytorch = "python -m pip install --upgrade torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/"
+
+    run_cmd(f"{install_pytorch}", assert_success=True, environment=True)
+
+
 def is_installed():
     site_packages_path = None
     for sitedir in site.getsitepackages():
@@ -129,8 +165,7 @@ def print_big_message(message):
     lines = message.split('\n')
     print("\n\n*******************************************************************")
     for line in lines:
-        if line.strip() != '':
-            print("*", line)
+        print("*", line)
 
     print("*******************************************************************\n\n")
 
@@ -165,26 +200,51 @@ def run_cmd(cmd, assert_success=False, environment=False, capture_output=False,
     return result
 
 
+def generate_alphabetic_sequence(index):
+    result = ''
+    while index >= 0:
+        index, remainder = divmod(index, 26)
+        result = chr(ord('A') + remainder) + result
+        index -= 1
+
+    return result
+
+
+def get_user_choice(question, options_dict):
+    print()
+    print(question)
+    print()
+
+    for key, value in options_dict.items():
+        print(f"{key}) {value}")
+
+    print()
+
+    choice = input("Input> ").upper()
+    while choice not in options_dict.keys():
+        print("Invalid choice. Please try again.")
+        choice = input("Input> ").upper()
+
+    return choice
+
+
 def install_webui():
-    # Select your GPU, or choose to run in CPU mode
+
+    # Ask the user for the GPU vendor
     if "GPU_CHOICE" in os.environ:
         choice = os.environ["GPU_CHOICE"].upper()
         print_big_message(f"Selected GPU choice \"{choice}\" based on the GPU_CHOICE environment variable.")
     else:
-        print()
-        print("What is your GPU?")
-        print()
-        print("A) NVIDIA")
-        print("B) AMD (Linux/MacOS only. Requires ROCm SDK 5.6 on Linux)")
-        print("C) Apple M Series")
-        print("D) Intel Arc (IPEX)")
-        print("N) None (I want to run models in CPU mode)")
-        print()
-
-        choice = input("Input> ").upper()
-        while choice not in 'ABCDN':
-            print("Invalid choice. Please try again.")
-            choice = input("Input> ").upper()
+        choice = get_user_choice(
+            "What is your GPU?",
+            {
+                'A': 'NVIDIA',
+                'B': 'AMD (Linux/MacOS only. Requires ROCm SDK 5.6 on Linux)',
+                'C': 'Apple M Series',
+                'D': 'Intel Arc (IPEX)',
+                'N': 'None (I want to run models in CPU mode)'
+            },
+        )
 
     gpu_choice_to_name = {
         "A": "NVIDIA",
@@ -195,24 +255,21 @@ def install_webui():
     }
 
     selected_gpu = gpu_choice_to_name[choice]
+    use_cuda118 = "N"
 
+    # Write a flag to CMD_FLAGS.txt for CPU mode
     if selected_gpu == "NONE":
         with open(cmd_flags_path, 'r+') as cmd_flags_file:
             if "--cpu" not in cmd_flags_file.read():
                 print_big_message("Adding the --cpu flag to CMD_FLAGS.txt.")
-                cmd_flags_file.write("\n--cpu")
-
-    # Find the proper Pytorch installation command
-    install_git = "conda install -y -k ninja git"
-    install_pytorch = "python -m pip install torch==2.1.* torchvision==0.16.* torchaudio==2.1.* "
+                cmd_flags_file.write("\n--cpu\n")
 
-    use_cuda118 = "N"
-    if any((is_windows(), is_linux())) and selected_gpu == "NVIDIA":
+    # Check if the user wants CUDA 11.8
+    elif any((is_windows(), is_linux())) and selected_gpu == "NVIDIA":
         if "USE_CUDA118" in os.environ:
             use_cuda118 = "Y" if os.environ.get("USE_CUDA118", "").lower() in ("yes", "y", "true", "1", "t", "on") else "N"
         else:
-            # Ask for CUDA version if using NVIDIA
-            print("\nDo you want to use CUDA 11.8 instead of 12.1? Only choose this option if your GPU is very old (Kepler or older).\nFor RTX and GTX series GPUs, say \"N\". If unsure, say \"N\".\n")
+            print("\nDo you want to use CUDA 11.8 instead of 12.1?\nOnly choose this option if your GPU is very old (Kepler or older).\n\nFor RTX and GTX series GPUs, say \"N\".\nIf unsure, say \"N\".\n")
             use_cuda118 = input("Input (Y/N)> ").upper().strip('"\'').strip()
             while use_cuda118 not in 'YN':
                 print("Invalid choice. Please try again.")
@@ -220,29 +277,35 @@ def install_webui():
 
         if use_cuda118 == 'Y':
             print("CUDA: 11.8")
-            install_pytorch += "--index-url https://download.pytorch.org/whl/cu118"
         else:
             print("CUDA: 12.1")
-            install_pytorch += "--index-url https://download.pytorch.org/whl/cu121"
-    elif not is_macos() and selected_gpu == "AMD":
-        if is_linux():
-            install_pytorch += "--index-url https://download.pytorch.org/whl/rocm5.6"
+
+    # No PyTorch for AMD on Windows (?)
+    elif is_windows() and selected_gpu == "AMD":
+        print("PyTorch setup on Windows is not implemented yet. Exiting...")
+        sys.exit(1)
+
+    # Find the Pytorch installation command
+    install_pytorch = f"python -m pip install torch=={TORCH_VERSION} torchvision=={TORCHVISION_VERSION} torchaudio=={TORCHAUDIO_VERSION} "
+
+    if selected_gpu == "NVIDIA":
+        if use_cuda118 == 'Y':
+            install_pytorch += "--index-url https://download.pytorch.org/whl/cu118"
         else:
-            print("AMD GPUs are only supported on Linux. Exiting...")
-            sys.exit(1)
-    elif is_linux() and selected_gpu in ["APPLE", "NONE"]:
+            install_pytorch += "--index-url https://download.pytorch.org/whl/cu121"
+    elif selected_gpu == "AMD":
+        install_pytorch += "--index-url https://download.pytorch.org/whl/rocm5.6"
+    elif selected_gpu in ["APPLE", "NONE"]:
         install_pytorch += "--index-url https://download.pytorch.org/whl/cpu"
     elif selected_gpu == "INTEL":
-        install_pytorch = "python -m pip install torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/"
+        if is_linux():
+            install_pytorch = "python -m pip install torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/"
+        else:
+            install_pytorch = "python -m pip install torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/"
 
     # Install Git and then Pytorch
     print_big_message("Installing PyTorch.")
-    run_cmd(f"{install_git} && {install_pytorch} && python -m pip install py-cpuinfo==9.0.0", assert_success=True, environment=True)
-
-    # Install CUDA libraries (this wasn't necessary for Pytorch before...)
-    if selected_gpu == "NVIDIA":
-        print_big_message("Installing the CUDA runtime libraries.")
-        run_cmd(f"conda install -y -c \"nvidia/label/{'cuda-12.1.1' if use_cuda118 == 'N' else 'cuda-11.8.0'}\" cuda-runtime", assert_success=True, environment=True)
+    run_cmd(f"conda install -y -k ninja git && {install_pytorch} && python -m pip install py-cpuinfo==9.0.0", assert_success=True, environment=True)
 
     if selected_gpu == "INTEL":
         # Install oneAPI dependencies via conda
@@ -255,47 +318,49 @@ def install_webui():
     update_requirements(initial_installation=True)
 
 
-def update_requirements(initial_installation=False):
+def get_extensions_names():
+    return [foldername for foldername in os.listdir('extensions') if os.path.isfile(os.path.join('extensions', foldername, 'requirements.txt'))]
+
+
+def install_extensions_requirements():
+    print_big_message("Installing extensions requirements.\nSome of these may fail on Windows.\nDon\'t worry if you see error messages, as they will not affect the main program.")
+    extensions = get_extensions_names()
+    for i, extension in enumerate(extensions):
+        print(f"\n\n--- [{i+1}/{len(extensions)}]: {extension}\n\n")
+        extension_req_path = os.path.join("extensions", extension, "requirements.txt")
+        run_cmd(f"python -m pip install -r {extension_req_path} --upgrade", assert_success=False, environment=True)
+
+
+def update_requirements(initial_installation=False, pull=True):
     # Create .git directory if missing
     if not os.path.exists(os.path.join(script_dir, ".git")):
         git_creation_cmd = 'git init -b main && git remote add origin https://github.com/oobabooga/text-generation-webui && git fetch && git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main && git reset --hard origin/main && git branch --set-upstream-to=origin/main'
         run_cmd(git_creation_cmd, environment=True, assert_success=True)
 
-    files_to_check = [
-        'start_linux.sh', 'start_macos.sh', 'start_windows.bat', 'start_wsl.bat',
-        'update_linux.sh', 'update_macos.sh', 'update_windows.bat', 'update_wsl.bat',
-        'one_click.py'
-    ]
-
-    before_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
-    run_cmd("git pull --autostash", assert_success=True, environment=True)
-    after_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
-
-    # Check for differences in installation file hashes
-    for file_name in files_to_check:
-        if before_pull_hashes[file_name] != after_pull_hashes[file_name]:
-            print_big_message(f"File '{file_name}' was updated during 'git pull'. Please run the script again.")
-            exit(1)
-
-    # Extensions requirements are installed only during the initial install by default.
-    # That can be changed with the INSTALL_EXTENSIONS environment variable.
-    install = initial_installation
-    if "INSTALL_EXTENSIONS" in os.environ:
-        install = os.environ["INSTALL_EXTENSIONS"].lower() in ("yes", "y", "true", "1", "t", "on")
-
-    if install:
-        print_big_message("Installing extensions requirements.")
-        skip = ['superbooga', 'superboogav2', 'coqui_tts']  # Fail to install on Windows
-        extensions = [foldername for foldername in os.listdir('extensions') if os.path.isfile(os.path.join('extensions', foldername, 'requirements.txt'))]
-        extensions = [x for x in extensions if x not in skip]
-        for i, extension in enumerate(extensions):
-            print(f"\n\n--- [{i+1}/{len(extensions)}]: {extension}\n\n")
-            extension_req_path = os.path.join("extensions", extension, "requirements.txt")
-            run_cmd(f"python -m pip install -r {extension_req_path} --upgrade", assert_success=False, environment=True)
-    elif initial_installation:
-        print_big_message("Will not install extensions due to INSTALL_EXTENSIONS environment variable.")
-
-    # Detect the Python and PyTorch versions
+    if pull:
+        print_big_message("Updating the local copy of the repository with \"git pull\"")
+
+        files_to_check = [
+            'start_linux.sh', 'start_macos.sh', 'start_windows.bat', 'start_wsl.bat',
+            'update_linux.sh', 'update_macos.sh', 'update_windows.bat', 'update_wsl.bat',
+            'one_click.py'
+        ]
+
+        before_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
+        run_cmd("git pull --autostash", assert_success=True, environment=True)
+        after_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
+
+        # Check for differences in installation file hashes
+        for file_name in files_to_check:
+            if before_pull_hashes[file_name] != after_pull_hashes[file_name]:
+                print_big_message(f"File '{file_name}' was updated during 'git pull'. Please run the script again.")
+                exit(1)
+
+    # Update PyTorch
+    if not initial_installation:
+        update_pytorch()
+
+    # Detect the PyTorch version
     torver = torch_version()
     is_cuda = '+cu' in torver
     is_cuda118 = '+cu118' in torver  # 2.1.0+cu118
@@ -335,11 +400,6 @@ def update_requirements(initial_installation=False):
         run_cmd(f"python -m pip uninstall -y {package_name}", environment=True)
         print(f"Uninstalled {package_name}")
 
-    # Make sure that API requirements are installed (temporary)
-    extension_req_path = os.path.join("extensions", "openai", "requirements.txt")
-    if os.path.exists(extension_req_path):
-        run_cmd(f"python -m pip install -r {extension_req_path} --upgrade", environment=True)
-
     # Install/update the project requirements
     run_cmd("python -m pip install -r temp_requirements.txt --upgrade", assert_success=True, environment=True)
     os.remove('temp_requirements.txt')
@@ -364,19 +424,49 @@ def launch_webui():
     check_env()
 
     parser = argparse.ArgumentParser(add_help=False)
-    parser.add_argument('--update', action='store_true', help='Update the web UI.')
+    parser.add_argument('--update-wizard', action='store_true', help='Launch a menu with update options.')
     args, _ = parser.parse_known_args()
 
-    if args.update:
-        update_requirements()
+    if args.update_wizard:
+        while True:
+            choice = get_user_choice(
+                "What would you like to do?",
+                {
+                    'A': 'Update the web UI',
+                    'B': 'Install/update extensions requirements',
+                    'C': 'Revert local changes to repository files with \"git reset --hard\"',
+                    'N': 'Nothing (exit)'
+                },
+            )
+
+            if choice == 'A':
+                update_requirements()
+            elif choice == 'B':
+                choices = {'A': 'All extensions'}
+                for i, name in enumerate(get_extensions_names()):
+                    key = generate_alphabetic_sequence(i + 1)
+                    choices[key] = name
+
+                choice = get_user_choice("What extension?", choices)
+
+                if choice == 'A':
+                    install_extensions_requirements()
+                else:
+                    extension_req_path = os.path.join("extensions", choices[choice], "requirements.txt")
+                    run_cmd(f"python -m pip install -r {extension_req_path} --upgrade", assert_success=False, environment=True)
+
+                update_requirements(pull=False)
+            elif choice == 'C':
+                run_cmd("git reset --hard", assert_success=True, environment=True)
+            elif choice == 'N':
+                sys.exit()
     else:
-        # If webui has already been installed, skip and run
         if not is_installed():
             install_webui()
             os.chdir(script_dir)
 
         if os.environ.get("LAUNCH_AFTER_INSTALL", "").lower() in ("no", "n", "false", "0", "f", "off"):
-            print_big_message("Install finished successfully and will now exit due to LAUNCH_AFTER_INSTALL.")
+            print_big_message("Will now exit due to LAUNCH_AFTER_INSTALL.")
             sys.exit()
 
         # Check if a model has been downloaded yet
@@ -388,7 +478,7 @@ def launch_webui():
             model_dir = 'models'
 
         if len([item for item in glob.glob(f'{model_dir}/*') if not item.endswith(('.txt', '.yaml'))]) == 0:
-            print_big_message("WARNING: You haven't downloaded any model yet.\nOnce the web UI launches, head over to the \"Model\" tab and download one.")
+            print_big_message("You haven't downloaded any model yet.\nOnce the web UI launches, head over to the \"Model\" tab and download one.")
 
         # Workaround for llama-cpp-python loading paths in CUDA env vars even if they do not exist
         conda_path_bin = os.path.join(conda_env_path, "bin")


Test patch: