gpt4 book ai didi

CUDA 内核失败 : no kernel image is available for execution on the device, 在 Google Compute VM 中运行 PyTorch 模型时出错

转载 作者:行者123 更新时间:2023-12-04 10:21:21 27 4
gpt4 key购买 nike

我有一个 PyTorch 模型的 docker 图像,当在 debian/Tesla P4 GPU/google 深度学习图像上运行的 google 计算引擎 VM 中运行时,该模型返回此错误:

CUDA kernel failed : no kernel image is available for execution on the device

这发生在调用我的模型的行上。 PyTorch 模型包括自定义 C++ 扩展,我正在使用此模型 https://github.com/daveredrum/Pointnet2.ScanNet

我的图像在运行时安装这些

该图像在我的本地系统上运行良好。 VM 和我的系统都有这些版本:

Cuda编译工具10.1、V10.1.243

火炬 1.4.0

火炬视觉 0.5.0

据我所知,主要区别在于 GPU

本地的:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21 Driver Version: 435.21 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 960M Off | 00000000:01:00.0 Off | N/A |
| N/A 36C P8 N/A / N/A | 361MiB / 2004MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

虚拟机:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.01 Driver Version: 418.87.01 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla P4 Off | 00000000:00:04.0 Off | 0 |
| N/A 42C P0 23W / 75W | 0MiB / 7611MiB | 3% Default |

如果我通过 ssh 进入虚拟机 torch.cuda.is_available()返回 true
因此我怀疑它一定与扩展的编译有关

这是我的 docker 文件的相关部分:
ENV CUDA_HOME "/usr/local/cuda-10.1"
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda-10.1/bin:${PATH}
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411 brand=tesla,driver>=418,driver<419"
ENV FORCE_CUDA=1

# CUDA 10.1-specific steps
RUN conda install -c open3d-admin open3d
RUN conda install -y -c pytorch \
cudatoolkit=10.1 \
"pytorch=1.4.0=py3.6_cuda10.1.243_cudnn7.6.3_0" \
"torchvision=0.5.0=py36_cu101" \
&& conda clean -ya
RUN pip install -r requirements.txt
RUN pip install flask
RUN pip install plyfile
RUN pip install scipy


# Install OpenCV3 Python bindings
RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \
libgtk2.0-0 \
libcanberra-gtk-module \
libgl1-mesa-glx \
&& sudo rm -rf /var/lib/apt/lists/*

RUN dir
RUN cd pointnet2 && python setup.py install
RUN cd ..

我已经在 VM 中从 ssh 重新运行了这一行:
TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0" python setup.py install

我认为哪个目标是安装到 Tesla P4 计算能力?

我可以尝试其他一些设置或故障排除步骤吗?

直到几天前,我才对 docker/VMs/pytorch 扩展一无所知,所以有点在黑暗中拍摄。这也是我的第一个 stackoverflow 帖子,如果我没有遵守一些礼仪,请随时指出。

最佳答案

我最终通过手动删除包含 setup.py 的文件夹中除“src”之外的所有文件夹解决了这个问题

然后重建docker镜像

然后在构建图像时我运行 TORCH_CUDA_ARCH_LIST="6.1" python setup.py install , 在 VM 上安装针对 GPU 正确计算能力的 cuda 扩展

它奏效了!

我想只运行 setup.py 而不删除以前安装的文件夹并不能完全覆盖扩展

关于CUDA 内核失败 : no kernel image is available for execution on the device, 在 Google Compute VM 中运行 PyTorch 模型时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60829433/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com