文章目录1、是否装了nvidia显卡驱动是否正常等。2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)pip命令查看torch版本校验cuda代码上一秒cuda还可用突然就不可用了为什么明明有显卡打游戏等也正常但是cuda是false有显卡一定支持cuda吗?cuda可用的情况下查看显卡型号和内存调用cuda之前都会先验证下cuda是否可用。如果不可用可以从如下几个方面排查1、是否装了nvidia显卡驱动是否正常等。2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)1、是否装了nvidia显卡驱动是否正常等。查看显卡版本命令nvidia-smi输出结果Wed Mar2517:08:112026-----------------------------------------------------------------------------------------|NVIDIA-SMI582.28Driver Version:582.28CUDA Version:13.0|---------------------------------------------------------------------------------------|GPU Name Driver-Model|Bus-Id Disp.A|Volatile Uncorr. ECC||Fan Temp Perf Pwr:Usage/Cap|Memory-Usage|GPU-Util Compute M.||||MIG M.||||0NVIDIA GeForce GTX 850M WDDM|00000000:01:00.0 Off|N/A||N/A 0C P8 N/A / 26W|56MiB / 2048MiB|0% Default||||N/A|---------------------------------------------------------------------------------------2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)大多数是因为这个问题。安装命令正确命令 pip install torch torchvision torchaudio--index-url https://download.pytorch.org/whl/cu118 错误命令也不是说这个命令是错的而是对于想用cuda能力的场景来说这样安装是错的 pip install torchpip命令查看torch版本命令pip show torch输出结果这种是cpu版本 Version:2.11.0 这种是cuda版本 Version:2.7.1cu118校验cuda代码代码importtorchprint(torch.__version__)print(torch.version.cuda)# 如果是 None说明装的是 CPU 版print(torch.cuda.is_available())上一秒cuda还可用突然就不可用了可能被覆盖了重新装下pipinstalltorch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 --force-reinstall为什么明明有显卡打游戏等也正常但是cuda是false按之前步骤排查大多数是torch版本问题。有显卡一定支持cuda吗?不一定目前主要是nvidia的显卡才可能支持cuda而且一些老版本的nvidia显卡是不支持cuda的。也就是非nvidia显卡基本不支持。nvidia显卡-老版本如GT系列显卡(如GT210)不支持。nvidia显卡-高版本大多数支持。cuda可用的情况下查看显卡型号和内存代码not_available_tip cuda 不可用。请检查 1. 是否安装了 NVIDIA 驱动 2. 是否安装了 cuda 版本的 pytorch iftorch.cuda.is_available():print(fcuda 可用显卡型号:{torch.cuda.get_device_name(0)})print(f显存总量:{torch.cuda.get_device_properties(0).total_memory/1024**2:.2f}MB)else:print(not_available_tip)
python查看显卡是否支持cuda、torch的cuda是否可用
发布时间:2026/5/27 9:34:16
文章目录1、是否装了nvidia显卡驱动是否正常等。2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)pip命令查看torch版本校验cuda代码上一秒cuda还可用突然就不可用了为什么明明有显卡打游戏等也正常但是cuda是false有显卡一定支持cuda吗?cuda可用的情况下查看显卡型号和内存调用cuda之前都会先验证下cuda是否可用。如果不可用可以从如下几个方面排查1、是否装了nvidia显卡驱动是否正常等。2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)1、是否装了nvidia显卡驱动是否正常等。查看显卡版本命令nvidia-smi输出结果Wed Mar2517:08:112026-----------------------------------------------------------------------------------------|NVIDIA-SMI582.28Driver Version:582.28CUDA Version:13.0|---------------------------------------------------------------------------------------|GPU Name Driver-Model|Bus-Id Disp.A|Volatile Uncorr. ECC||Fan Temp Perf Pwr:Usage/Cap|Memory-Usage|GPU-Util Compute M.||||MIG M.||||0NVIDIA GeForce GTX 850M WDDM|00000000:01:00.0 Off|N/A||N/A 0C P8 N/A / 26W|56MiB / 2048MiB|0% Default||||N/A|---------------------------------------------------------------------------------------2、torch版本必须是cuda版本如果不指定默认装的是cpu版本。(重)大多数是因为这个问题。安装命令正确命令 pip install torch torchvision torchaudio--index-url https://download.pytorch.org/whl/cu118 错误命令也不是说这个命令是错的而是对于想用cuda能力的场景来说这样安装是错的 pip install torchpip命令查看torch版本命令pip show torch输出结果这种是cpu版本 Version:2.11.0 这种是cuda版本 Version:2.7.1cu118校验cuda代码代码importtorchprint(torch.__version__)print(torch.version.cuda)# 如果是 None说明装的是 CPU 版print(torch.cuda.is_available())上一秒cuda还可用突然就不可用了可能被覆盖了重新装下pipinstalltorch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 --force-reinstall为什么明明有显卡打游戏等也正常但是cuda是false按之前步骤排查大多数是torch版本问题。有显卡一定支持cuda吗?不一定目前主要是nvidia的显卡才可能支持cuda而且一些老版本的nvidia显卡是不支持cuda的。也就是非nvidia显卡基本不支持。nvidia显卡-老版本如GT系列显卡(如GT210)不支持。nvidia显卡-高版本大多数支持。cuda可用的情况下查看显卡型号和内存代码not_available_tip cuda 不可用。请检查 1. 是否安装了 NVIDIA 驱动 2. 是否安装了 cuda 版本的 pytorch iftorch.cuda.is_available():print(fcuda 可用显卡型号:{torch.cuda.get_device_name(0)})print(f显存总量:{torch.cuda.get_device_properties(0).total_memory/1024**2:.2f}MB)else:print(not_available_tip)