宁夏建设造价网站,厦门微信网站建设,国外做图片识别训练的网站,做国际网站装修CUDA可用#xff0c;共有 1 个GPU设备可用。 当前使用的GPU设备索引#xff1a;0 当前使用的GPU设备名称#xff1a;NVIDIA T1000 GPU显存总量#xff1a;4.00 GB 已使用的GPU显存#xff1a;0.00 GB 剩余GPU显存#xff1a;4.00 GB PyTorch版本#xff1a;1.10.1cu102 …CUDA可用共有 1 个GPU设备可用。 当前使用的GPU设备索引0 当前使用的GPU设备名称NVIDIA T1000 GPU显存总量4.00 GB 已使用的GPU显存0.00 GB 剩余GPU显存4.00 GB PyTorch版本1.10.1cu102
import torch# 检查CUDA是否可用
cuda_available torch.cuda.is_available()if cuda_available:# 获取GPU设备数量num_gpu torch.cuda.device_count()# 获取当前使用的GPU索引current_gpu_index torch.cuda.current_device()# 获取当前GPU的名称current_gpu_name torch.cuda.get_device_name(current_gpu_index)# 获取GPU显存的总量和已使用量total_memory torch.cuda.get_device_properties(current_gpu_index).total_memory / (1024 ** 3) # 显存总量(GB)used_memory torch.cuda.memory_allocated(current_gpu_index) / (1024 ** 3) # 已使用显存(GB)free_memory total_memory - used_memory # 剩余显存(GB)print(fCUDA可用共有 {num_gpu} 个GPU设备可用。)print(f当前使用的GPU设备索引{current_gpu_index})print(f当前使用的GPU设备名称{current_gpu_name})print(fGPU显存总量{total_memory:.2f} GB)print(f已使用的GPU显存{used_memory:.2f} GB)print(f剩余GPU显存{free_memory:.2f} GB)
else:print(CUDA不可用。)# 检查PyTorch版本
print(fPyTorch版本{torch.__version__})
windows先装显卡驱动再装CUDA10.2最后装了pytorch。
pip install torch1.10.1cu102 torchvision0.13.1cu102 torchaudio0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102