You're reading...
Uncategorized

torch.cuda.is_available() = False πŸ™„

Just posting this for absolutely my own benefit. I recorded it somewhere before but I keep misplacing the information. πŸ™ƒ


Every time I create a Python virtual environment (GitHub – raidenworks/create_virtual_env: Windows batch file for quickly creating python virtual environment) for segregating projects and their package dependencies, and where the project would benefit from having training or inference be run through the GPU, I find I have to dig for information on installing torch in the environment. It involves a fair bit of research and I’m just logging here what I’ve done most recently. (I’m running Windows 10 with a RTX 2080.)

This assumes:

  1. CUDA is already installed. (https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html)
  2. Fresh virtual environment is already created.

A check shows CUDA is installed:

But not available:

Specifically for my CUDA version, this is my install command (after faffing around looking at https://pytorch.org/get-started/previous-versions/ and working through the below):

pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2+cu117 --extra-index-url https://download.pytorch.org/whl/cu117

In the above, we see the installation is using the previously downloaded and cached Python Wheel (.whl) for torch==2.0.1+cu117. I had previously run the pip install with deprecated versions for torchvision and torchaudio and it caused the installation to just stop after torch was downloaded.

Re-running it again gave this:

Which nicely shows the error message for the torchvision version not buried in the middle of the extensively long torch Python Wheel download status seen in the prior pip install. Just pick the highest version number with +cu117, 0.15.0+cu117, and similarly for torchaudio too, which was 2.0.2+cu117.

The total time should take around 24 minutes, with the bulk of data from the 2.3 GB torch package. Something to note if you have limited space for additional virtual environments.

Net result:

Discussion

Comments are closed.

Archives

Visitors

Flag Counter