更新时间:2024-04-11 GMT+08:00

重装的包与镜像装CUDA版本不匹配

问题现象

在现有镜像基础上,重新装了引擎版本,或者编译了新的CUDA包,出现如下错误:
1.“RuntimeError: cuda runtime error (11) : invalid argument at /pytorch/aten/src/THC/THCCachingHostAllocator.cpp:278”
2.“libcudart.so.9.0 cannot open shared object file no such file or directory”
3.“Make sure the device specification refers to a valid device, The requested device appeares to be a GPU,but CUDA is not enabled”

原因分析

出现该问题的可能原因如下:

新安装的包与镜像中带的CUDA版本不匹配。

处理方法

必现的问题,使用本地Pycharm远程连接Notebook调试安装。
  1. 先远程登录到所选的镜像,使用“nvcc -V”查看目前镜像自带的CUDA版本。
  2. 重装torch等,需要注意选择与上一步版本相匹配的版本。

建议与总结

在创建训练作业前,推荐您先使用ModelArts开发环境调试训练代码,避免代码迁移过程中的错误。