Prebuilt versions of PyTorch only support specific CUDA versions and systems to date. To ensure that your GPU is truly unsupported, visit the official NVIDIA CUDA-enabled GPU list to see if your GPU is listed. If it’s not, it might be too old or not meet the minimum requirements for CUDA support.
When an unsupported device installs PyTorch, it gets the generic error: RuntimeError: CUDA error: no kernel image is available for execution on the device
. Luckily, there are multiple ways to counter this issue, as listed below.
In case of your GPU not being supported, you can still install the CPU-only version of PyTorch. However, the downside of this is that the CPU would be utilized instead of the GPU. You won't be able to enjoy the benefits of GPU acceleration, but it will allow you to use PyTorch on your system.
The pip
command (or pip3
in the case of Python 3 instead of Python 2) is shown below:
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
Note: For PyTorch to work correctly, we also need to install
torchvision
andtorchaudio
as well.
To confirm whether the installation has been successful, we can use the following Python script:
import torchprint(torch.__version__)
In the code widget above, the first line imports the PyTorch library, followed by the print
statement displaying the PyTorch version previously installed via the torch.version
method.
Another way of confirming whether the installation has been successful is by entering the following command into the command prompt on your system:
pip show torch
Let's click on the terminal down below to get an idea of how the output of the pip show torch
command will look like.
Note: If the command above gives the error:
pip: command not found
, use the following command as an alternative:pip3 show torch
.
For GPUs that lack official support but exhibit some compatibility, consider building PyTorch from source with GPU support. This approach involves a more advanced process, potentially requiring modifications to the PyTorch source code to accommodate the unique features or limitations of the unsupported GPU.
You can find detailed instructions for building PyTorch from source in the official PyTorch repository.
At times, the open-source community created unofficial forks or versions of PyTorch that add support for certain unsupported GPUs. It is suggested to search online for various Github repositories or Stack Overflow forums to see if there are any projects for your specific GPU.
Apart from the three methods mentioned above, we could use GPU emulation techniques at the expense of performance. For instance, we might use tools like CUDA Emu (primarily intended for software development and testing rather than running complex machine learning models). Before trying to install such tools, we must install the necessary dependencies, such as CUDA Toolkit and cuDNN (if not already installed). These libraries are essential for GPU acceleration in PyTorch.
Some of these steps are not guaranteed to work and may lead to issues such as lag in performance or an unstable coding environment. While the GPU might not be supported now, future releases of PyTorch may include improvements or changes that provide limited support.
Free Resources