前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MindSpore运行报错RuntimeError: Unsupported device target GPU解决方案

MindSpore运行报错RuntimeError: Unsupported device target GPU解决方案

作者头像
DechinPhy
发布2024-04-16 08:28:00
2961
发布2024-04-16 08:28:00
举报
文章被收录于专栏:Dechin的专栏Dechin的专栏

问题背景

在运行MindSpore程序时,设置device_target为GPU,结果运行时报错:

代码语言:javascript
复制
RuntimeError: Unsupported device target GPU. This process only supports one of the ['CPU']. Please check whether the GPU environment is installed and configured correctly, and check whether current mindspore wheel package was built with "-e GPU". For details, please refer to "Device load error message".

----------------------------------------------------
- Device load error message:
----------------------------------------------------
Load dynamic library: libmindspore_ascend.so.2 failed. libge_runner.so: cannot open shared object file: No such file or directory

----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore/core/utils/ms_context.cc:355 SetDeviceTargetFromInner

问题分析和解决

这个报错说明安装MindSpore时没有正确配置,导致只能识别到CPU设备。如果本地有CUDA环境,可以直接把CUDA路径配置到环境变量里面去,这样就能正确找到CUDA的应用。这里我们的CUDA路径为:/usr/local/cuda-10.1:

代码语言:javascript
复制
$ ll /usr/local/cuda-10.1/
总用量 136
drwxr-xr-x 18 root root  4096 7月  13  2021 ./
drwxr-xr-x 22 root root  4096 3月  18 17:26 ../
drwxr-xr-x  3 root root  4096 7月  13  2021 bin/
drwxr-xr-x  5 root root  4096 7月  13  2021 doc/
-rw-r--r--  1 root root 59776 7月  13  2021 EULA.txt
drwxr-xr-x  6 root root  4096 7月  13  2021 extras/
lrwxrwxrwx  1 root root    28 7月  13  2021 include -> targets/x86_64-linux/include/
drwxr-xr-x  5 root root  4096 7月  13  2021 jre/
lrwxrwxrwx  1 root root    24 7月  13  2021 lib64 -> targets/x86_64-linux/lib/
drwxr-xr-x  8 root root  4096 7月  13  2021 libnsight/
drwxr-xr-x  7 root root  4096 7月  13  2021 libnvvp/
drwxr-xr-x  7 root root  4096 7月  13  2021 NsightCompute-2019.1/
drwxr-xr-x  2 root root  4096 7月  13  2021 nsightee_plugins/
drwxr-xr-x  4 root root  4096 7月  13  2021 NsightSystems-2018.3/
drwxr-xr-x  3 root root  4096 7月  13  2021 nvml/
drwxr-xr-x  7 root root  4096 7月  13  2021 nvvm/
drwxr-xr-x 11 root root  4096 7月  13  2021 samples/
drwxr-xr-x  3 root root  4096 7月  13  2021 share/
drwxr-xr-x  2 root root  4096 7月  13  2021 src/
drwxr-xr-x  3 root root  4096 7月  13  2021 targets/
drwxr-xr-x  2 root root  4096 7月  13  2021 tools/
-rw-r--r--  1 root root    22 7月  13  2021 version.txt

然后把这个路径直接加到环境变量CUDA_HOME里面去即可:

代码语言:javascript
复制
$ export CUDA_HOME=/usr/local/cuda-10.1/

配置完成后,再次运行MindSpore程序,就没有报错了。因为export是临时配置,如果不想每次都配置一遍,可以考虑把这个环境变量的配置写到.bashrc环境变量配置文件里面去。

总结概要

本文主要介绍了一个关于MindSpore运行报错RuntimeError的解决方案。这个报错的内容提示信息说的是安装完成MindSpore之后,找不到GPU的CUDA环境,只能使用CPU运行环境。出现这个报错是因为手动编译安装MindSpore之后,需要配置一些环境变量。而如果是使用pip或者conda安装mindspore的话,会自动的识别到CUDA环境并添加到环境变量中去。因此,解决这个报错,我们只需要把相关的CUDA环境路径添加到环境变量中即可。

版权声明

本文首发链接为:https://www.cnblogs.com/dechinphy/p/cuda_home.html

作者ID:DechinPhy

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-04-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 问题背景
  • 问题分析和解决
  • 总结概要
  • 版权声明
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档