Pytorch >= 2.1 is no more able to use my GPU :(

With all versions of PyTorch >= 2.1 I have this error:
RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
If I disable the check, it uses the CPU.

Older PyTorch 2.0.1 works perfectly on my system though, I still use it for the old version of ForgeUI. New versions of ForgeUI however need at least version 2.1 of PyTorch, else it says: AttributeError: module 'torch' has no attribute 'float8_e4m3fn'.

Can someone help, please?

Windows 7, Cuda11.4, RTX3060, Python 3.10.14

What does torch.__version__ and torch.version.cuda return?

I can’t execute torch.__version__ because import torch gives me an error about missing dependencies for c10_cuda.dll. :frowning:

import torch
Traceback (most recent call last):
File “”, line 1, in
File “D:\apps\stable-diffusion\Forge_20240811_121_21\system\python\lib\site-pa
ckages\torch_init_.py”, line 139, in
raise err
OSError: [WinError 126] Le module spécifié est introuvable. Error loading “D:\ap
ps\stable-diffusion\Forge_20240811_121_21\system\python\lib\site-packages\torch
lib\c10_cuda.dll” or one of its dependencies.

In this case you might need to fix this error first, which seems to break your import.
Based on your initial post I assume you are using some kind of wrapper and e.g. this error describes the same one caused by a specific workflow in ComfyUI.

I don’t know how to fix this error though. :frowning:
According to Dependency Walker the missing dependencies of c10_cuda.dll are two dlls that don’t seem to exist for Windows 7 and functions missing in Windows dll like kernel32.dll and ieframe.dll.

I do not use any function wrapper. I don’t know if Forge does.

I am the person in the link actually. I tried using the virtual environment from the older version of Forge or Automatic1111 but they give me this error: AttributeError: module 'torch' has no attribute 'float8_e4m3fn' which seemingly means that I need to update PyTorch to at least version 2.1, but when I do I always end up with the Torch is not able to use GPU error and missing dependencies for c10_cuda.dll.

So, is pytorch just not compatible with Windows 7 anymore?

The website says Windows 7 and greater though.

According to Microsoft web-site Windows 7 have reached end of life in 2020 should have been updated. That said, I don’t think there is anything that blocks it from working on Windows 7, perhaps all you need to do is to update Visual Studio runtime (if I’m not mistaken, in 2.1 we’ve switch from VS2017 to VS2019 builds)

1 Like

Yeah we all sometimes have to keep running a somewhat obsolete software or hardware for compatibility reason and to avoid e-wasting a still perfectly running machine. However of course I understand that you may not want to spend time testing if your code is still compatible with an oldish OS that a small percentage of your users still use.

I did install/repair all Visual Studio redistribuables, including 2019. I made all OS updates available and I checked the integrity of my system files.

I don’t know if I can trust Dependency Walker (some people say it sometimes reports false positives) but it reports that c10_cuda.dll now needs the ResolveDelayLoadedAPI function which is missing from kernel32.dll. From what I read this function may be only available on Windows 8+. :frowning: This problem only happens with version 2.1 and above.

It also reports these two modules missing from c10.dll:

??0Warning@c10@@QEAA@V?$variant@VUserWarning@Warning@c10@@VDeprecationWarning@23@@1@AEBUSourceLocation@1@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z

??0Warning@c10@@QEAA@V?$variant@VUserWarning@Warning@c10@@VDeprecationWarning@23@@1@USourceLocation@1@PEBD_N@Z

I did install VS runtime 2019 but it did not solve the problem. :frowning:
Is there a version of pytorch 2.1 build with VS2017 instead that I could try, to tell if this is what caused the problem?

It was indeed an incompatibility with Windows 7.
If someone ever has the same problem, here is how I fixed it:

Don’t replace the embed python with pythonwin7, it’s not necessary. Don’t replace any dll either.
If you copied “api-ms-win-security-systemfunctions-l1-1-0.dll” to “system32”, remove it.

Install VxKex (the original repo is dead, I don’t know which new source is safe to download it from: i486/VxKex / Blaukovitch/VxKex)
In VxKex settings, add Forge’s “system/python/python.exe”

Uninstall pytorch and reinstall a compatible version, without torchaudio.

python -m pip uninstall Torch Torchvision Torchaudio
python -m pip install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cu118

“LIBOMP140.X86_64.DLL” will be missing, it’s a known bug for pytorch 2.4.0. Download it, unzip and copy the dll in system32.
https://www.dllme.com/dll/files/libomp140_x86_64/00637fe34a6043031c9ae4c6cf0a891d

Voila.