选择要用的GPU: CUDA_VISIBLE_DEVICES

选择要用的GPU: CUDA_VISIBLE_DEVICES

在JetsonNX中使用PaddleHUB,要使用GPU来做目标检测时,出错,测试代码很简单:

import paddlehub as hub
import cv2

object_detector = hub.Module(name="yolov3_darknet53_coco2017")
                     
result = object_detector.object_detection(images=[cv2.imread('/home/nx/Pictures/kite.jpg')], use_gpu=True ,visualization=True)

print(result)

提示错误


nx@nx-desktop:~/mysoft/paddle_test$ python3 object_detect.py
[2020-12-11 14:34:18,790] [    INFO] - Installing yolov3_darknet53_coco2017 modu                                         le
[2020-12-11 14:34:18,992] [    INFO] - Module yolov3_darknet53_coco2017 already installed in /home/nx/.paddlehub/modules/yolov3_darknet53_coco2017
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the impmodule is deprecated in favour of importlib; see the module's documentation for                                          alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
  File "/home/nx/.paddlehub/modules/yolov3_darknet53_coco2017/module.py", line 185, in object_detection
    _places = os.environ["CUDA_VISIBLE_DEVICES"]
  File "/usr/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'CUDA_VISIBLE_DEVICES'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "object_detect.py", line 22, in <module>
    result = object_detector.object_detection(images=[cv2.imread('/home/nx/Pictures/kite.jpg')], use_gpu=True ,visualization=True)
  File "/home/nx/.paddlehub/modules/yolov3_darknet53_coco2017/module.py", line 189, in object_detection
    "Attempt to use GPU for prediction, but environment variable CUDA_VISIBLE_DEVICES was not set correctly."
RuntimeError: Attempt to use GPU for prediction, but environment variable CUDA_VISIBLE_DEVICES was not set correctly.

提示要设置“CUDA_VISIBLE_DEVICES”
不知道怎么弄,查找“CUDA_VISIBLE_DEVICES”,找到文章

选择要用的GPU: CUDA_VISIBLE_DEVICES

设置

linux:
在~/.bashrc 的最后加上export CUDA_VISIBLE_DEVICES=1,然后source ~/.bashrc
windows:
打开我的电脑环境变量设置的地方,直接添加就行了。

版权声明:本文为CSDN博主「阿许2014」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sdjkxhb/article/details/111035096

阿许2014

我还没有学会写个人说明!

暂无评论

发表评论

相关推荐

Imagenet2012数据集下载、介绍

最近研究可能会用到该数据集,发现过去好多分享的官网下载链接已经失效,找了很久才找到了网盘的数据集。
1、下载
链接1:https://pan.baidu.com/s/1sRbEZ8imECJu8ER

Pytorch 目标检测

                            版权声明:本文为CSDN博主「辉辉小学生」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请 ...