()
| 99 | |
| 100 | |
| 101 | def update_modules(): |
| 102 | import torchruntime |
| 103 | |
| 104 | if version("torch") is None: |
| 105 | torchruntime.install(["torch", "torchvision"]) |
| 106 | else: |
| 107 | torch_version_str = version("torch") |
| 108 | torch_version = version_str_to_tuple(torch_version_str) |
| 109 | is_cpu_torch = "+" not in torch_version_str |
| 110 | print(f"Current torch version: {torch_version} ({torch_version_str})") |
| 111 | if torch_version < (2, 7) or is_cpu_torch: |
| 112 | from torchruntime.device_db import get_gpus |
| 113 | |
| 114 | gpu_infos = get_gpus() |
| 115 | device_names = set(gpu.device_name for gpu in gpu_infos) |
| 116 | if any(BLACKWELL_DEVICES.search(device_name) for device_name in device_names): |
| 117 | if sys.version_info < (3, 9): |
| 118 | print( |
| 119 | "\n###################################\n" |
| 120 | "NVIDIA 50xx series of graphics cards detected!\n\n" |
| 121 | "To use this graphics card, please install the latest version of Easy Diffusion from: https://github.com/easydiffusion/easydiffusion#installation" |
| 122 | "\n###################################\n" |
| 123 | ) |
| 124 | sys.exit() |
| 125 | else: |
| 126 | print("Upgrading torch to support NVIDIA 50xx series of graphics cards") |
| 127 | torchruntime.install(["--force", "--upgrade", "torch", "torchvision"]) |
| 128 | |
| 129 | for module_name, allowed_versions in modules_to_check.items(): |
| 130 | if os.path.exists(f"src/{module_name}"): |
| 131 | print(f"Skipping {module_name} update, since it's in developer/editable mode") |
| 132 | continue |
| 133 | |
| 134 | allowed_versions, latest_version = get_allowed_versions(module_name, allowed_versions) |
| 135 | |
| 136 | if module_name == "setuptools": |
| 137 | if os_name == "Windows": |
| 138 | allowed_versions = ("59.8.0",) |
| 139 | latest_version = "59.8.0" |
| 140 | else: |
| 141 | allowed_versions = ("69.5.1",) |
| 142 | latest_version = "69.5.1" |
| 143 | |
| 144 | requires_install = version(module_name) not in allowed_versions |
| 145 | |
| 146 | if requires_install: |
| 147 | try: |
| 148 | install(module_name, latest_version) |
| 149 | except: |
| 150 | traceback.print_exc() |
| 151 | fail(module_name) |
| 152 | else: |
| 153 | if version(module_name) != latest_version: |
| 154 | print( |
| 155 | f"WARNING! Tried to install {module_name}=={latest_version}, but the version is still {version(module_name)}!" |
| 156 | ) |
| 157 | |
| 158 | # different sdkit versions, with the corresponding diffusers |
no test coverage detected