选择要用的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:
打开我的电脑环境变量设置的地方,直接添加就行了。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值