reinstall if torch-cpu and use-cuda or use-rocm

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-10-06 20:20:46 -04:00
parent 3fe1d090e4
commit fc472f3f3a
2 changed files with 13 additions and 2 deletions
+1
View File
@@ -39,6 +39,7 @@
`torch-directml` received no updates in over 1 year and its currently superceded by `rocm` or `zluda`
- command line params `--use-zluda` and `--use-rocm` will attempt desired operation or fail if not possible
previously sdnext was performing a fallback to `torch-cpu` which is not desired
- if `--use-cuda` or `--use-rocm` are specified and `torch-cpu` is installed, installer will attempt to reinstall correct torch package
- **installer**: warn if cuda or rocm are available and `torch-cpu` is installed
- **Extensions**
- [Agent-Scheduler](https://github.com/SipherAGI/sd-webui-agent-scheduler)
+12 -2
View File
@@ -953,9 +953,19 @@ def check_torch():
pass
if 'cpu' in torch.__version__:
if is_cuda_available:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and CUDA is available - consider reinstalling')
if args.use_cuda:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and CUDA is selected - reinstalling')
uninstall(['torch', 'torchvision'], quiet=True)
install(torch_command, 'torch torchvision', quiet=True) # foce reinstall
else:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and CUDA is available - consider reinstalling')
elif is_rocm_available:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and ROCm is available - consider reinstalling')
if args.use_rocm:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and ROCm is selected - reinstalling')
uninstall(['torch', 'torchvision'], quiet=True)
install(torch_command, 'torch torchvision', quiet=True) # foce reinstall
else:
log.warning(f'Torch: version="{torch.__version__}" CPU version installed and ROCm is available - consider reinstalling')
if hasattr(torch, "xpu") and torch.xpu.is_available() and allow_ipex:
if shutil.which('icpx') is not None:
log.info(f'{os.popen("icpx --version").read().rstrip()}')