我有一台配备 RTX 6000 ADA GPU 的机器。
我们曾经使用 CUDA 版本 11.x,我使用了以下图像:
nvcr.io/nvidia/pytorch:21.04-py3
(我使用 PyTorch 1.x)。
但是,我们机器上的驱动程序似乎已更新为以下 -
来自 nvidia-smi 命令的驱动程序信息:
NVIDIA-SMI 535.161.07 Driver Version: 535.161.07 CUDA Version: 12.2
现在我不断得到:
Segmentation fault (core dumped)
每当我尝试将张量移动到 cuda 设备时。
我认为这是 CUDA 版本问题,因此我尝试将图像更新为:
nvcr.io/nvidia/pytorch:23.02-py3
支持较新的 CUDA 版本,但问题仍然存在。这是导致该问题的示例程序:
import torch
tensor_cpu = torch.tensor([1, 2, 3, 4, 5])
print("Tensor device before moving to CUDA:", tensor_cpu.device)
if torch.cuda.is_available():
device = torch.device("cuda")
tensor_cuda = tensor_cpu.to(device)
print("Tensor device after moving to CUDA:", tensor_cuda.device)
else:
print("CUDA is not available. Cannot move tensor to CUDA.")
输出为:
Tensor device before moving to CUDA: cpu
Segmentation fault (core dumped)
我该如何修复它?我应该与我的 GPU 一起使用的正确图像(使用 PyTorch 1.x)是什么?
或者这个问题与其他事情有关?
Segmentation Fault
通常来自本机 C 上的意外内存访问。
可能是显卡驱动、Pytorch版本、CUDA和cuDNN版本兼容性等原因导致...
如果检查了所有兼容性,请尝试调查您的 GPU 内存分配,例如内存泄漏或 OOM。在我的例子中,大部分
Segmentation Fault
是由 GPU OOM 引起的。