ESRGAN with IEU using PyTorch 1.3.0 for compatibility with NVIDIA CUDA compute capability 3.5 on Windows 10

kid marscat
5 min readJun 6, 2021
ESRGAN example baboon, adding for header image only lol

I had to reinstall my system due to driver failure recently, and when I went to set-up ESRGAN/IEU again — following once again this great Windows install guide from Upscale Wiki — it just wasn’t working anymore. I got the following error, which I’ve seen elsewhere online too:

CUDA error: no kernel image is available for execution on the device

After a long night of research, and several reinstalls of both Python, Git, and my CUDA driver, I figured out that the actual problem is that PyTorch dropped support for NVIDIA GPUs with compute capability 3.5.

This means that my particular video card won’t be compatible with any available PyTorch package in the future, unless I build PyTorch from source myself, which is not something I can figure out on my own sadly — I’m an artist, not a programmer! Also, since I formatted my old Windows installation, I sadly couldn’t just go fetch my old set-up, so I had to find a way to remake my entire set-up any way I could, or I wouldn’t be able to use ESRGAN on this computer ever again ;c

Eventually I discovered something: There’s still a version of PyTorch, predating this GPU compatibility change, available on Anaconda. Exactly, PyTorch 1.3.0 with Torchvision 0.4.1 for CUDA 10.1, which however is only compatible with Python 3.7. This can all be sorted out from Anaconda though, so I’m writing here what I did on my end so you can do this too!

For reference, this is the conda pytorch package we will be installing.
And also the torchvision package we will install with pytorch 1.3.0

(Note that, unlike what it says on the Upscale Wiki’s guide, we won’t be needing to install Python or Git on Windows, since we will be installing Python 3.7 with Anaconda instead, and using its command prompt rather than Git Bash. This guide is therefore a replacement of sorts for that guide, for the most part.)

How to Install

1. Download and install the CUDA Toolkit for version 10.1. I actually have CUDA 11.1.1 installed and it works just fine, so see what works for you on your system.

2. Install Anaconda3.

(Note: You must add Anaconda3 to PATH. You can do this by editing the System Environment Variables yourself, as I did, or by selecting the option to “Add Anaconda3 to the system PATH environment variable” on the Anaconda installation program. I haven’t tested the latter option, however.)

3. Open Anaconda Prompt, and create a new conda environment targeting Python 3.7. There’s a helpful guide on how to do this here, but if you just want the commands, they will be posted below.

(For this example, the name for the conda environment I chose is esrgan as that’s what I’ll be using it for. You can change it from something else, though; just replace the name in every further command and set-up when necessary.)

conda create --name esrgan python=3.7 pip

4. Activate the new conda environment.

conda activate esrgan

5. Install pytorch and torchvision using conda:

conda install pytorch==1.3.0 torchvision==0.4.1 cudatoolkit=10.1 -c pytorch

(Note that the parameter here is cudatoolkit=XX.X and not cudatoolkit==xx.x. That is, only write one equal sign in there.)

6. After installing these packages and their dependencies, also install opencv-python, as required:

pip install opencv-python

7. Now we need to set-up IEU to be able to find our conda environment. To do this, we need to open IEU, go to settings, find the option box marked as Use conda environment: and check it, and in the text field next to it, write the name of our environment, which in this example is esrgan.

How this should look on the IEU settings tab.

Now close IEU for the time being.

8. However, this is not enough to have IEU find your conda environment. If you haven’t added Anaconda3 to your PATH, do so now. If you need a general overview regarding this, I recommend reading this article. In any case, you will need to find the Anaconda3 install folder (which is different depending on how you chose to install it), and its subfolder “Scripts”, and add both to your system environment variable.

(Why? The main folder is where Python 3.7 is installed, and Anaconda3/Scripts is where the conda command itself is located, and IEU needs to be able to find both to work.)

Your system environment variable PATH should look like this. The censored part will be different depending on where you chose to install Anaconda3.

9. Finally, we need to initialize the conda for shell integration, otherwise IEU won’t be able to send commands to your conda environment through the Windows shell. To do so, go back to Anaconda Prompt, activate your conda environment, and run the following command:

conda init cmd.exe

You should be able to close Anaconda Prompt now.

10. Reopen IEU. If everything went right, you should be able to run ESRGAN and see no errors. If not, please let me know in the comments!

Further thoughts

Sadly, I can’t really know for how long this solution will be available, as like with the 1.3.0 version of PyTorch for pip, these Anaconda packages might be removed at any point in the future. It’d be great if PyTorch had at least one version, for conda and/or pip, that remains available for people with NVIDIA GPU cards with CUDA CC 3.5, so that it’s easier for people in our situation, but this might easily never happen, as this is all “deprecated” by now.

Ideally, someone with a knowledge on how to build the PyTorch Windows binaries could keep a repository of the latest version of PyTorch properly configured to be compatible with CUDA CC 3.5, like Nelson Liu’s repository for Linux, but since I’m not a CUDA/python developer myself, I really don’t know how viable this might be. If anyone wants to give it a try, and needs a tester, please let me know!

Honestly, anything would beat having to Google your way into figuring out a workaround for this situation. It will always be better to have an official and simple option available, or someone providing a reliable alternative. Until then, however, I hope this set-up works for you for the time being.

Again, if you need any help (not that I’m an expert on any of this ha ha) please let me know in the comments!

--

--