Solve the problem of pytorch CUDA version inconsistency

View pytorch version

There are two ways:

  • The first type:
    output in python:
import torch
torch.cuda.is_available()
torch.cuda.version
  • The second:
    use conda list or pip list

Generally, you can see the version of torch and torchvision here, and then the cuda version was chosen to be installed at that time, and now there are 9.0, 10.1, and 10.2 versions. The corresponding can be seen.

Check the version supported by the graphics card

enter:

nvidia-smi

You can see:
== NVIDIA-SMI 430.40 Driver Version: 430.40 CUDA Version: 10.1 ==

Here 430 is the NVIDIA driver version. The highest supported CUDA version can be found on the official website. Then my CUDA version is 10.1. If you have 10.2 installed, it will not be supported. Use torch.cuda.is_available() and it will be reported. False.

View the configuration of environment variables

Edit /home/name/.bashrc to check whether the CUDA_HOME or CUDA_PATH is configured with the path of cuda. ​​Generally, cuda is in /usr/loca/cuda. ​​This path may be your real cuda soft connection. Whether the replacement is soft-connected to the corresponding cuda version, so that the version can be switched. Remember to source it after modification. Output the variable to see if it works. echo $CUDA_HOME.

summary

The basic configuration can be found by relying on these. For general version problems, refer to the corresponding check above to know where the problem is.

Guess you like

Origin blog.csdn.net/u012457196/article/details/108747105