早上在跑mxnet的mnist的示例代码时报错了,代码如下:

import mxnet as mx
ctx = mx.gpu(0) if mx.context.num_gpus() > 0 else mx.cpu(0)

报错如下:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-7adbfd3392ed> in <module>
----> 1 ctx = mx.gpu(0) if mx.context.num_gpus() > 0 else mx.cpu(0)2 net.initialize(mx.init.Xavier(), ctx=ctx)AttributeError: module 'mxnet.context' has no attribute 'num_gpus'

代码修改为如下就可以了:

import mxnet as mx
try:ctx = mx.gpu(0)
except Exception as e:ctx = mx.cpu(0)

mxnet报错解决:AttributeError: module 'mxnet.context' has no attribute 'num_gpus'相关推荐

  1. 程序报错:AttributeError: module ‘cv2.cv2‘ has no attribute ‘cv2.MultiTracker_create()‘

    问题1:pycharm运行程序时报错 AttributeError: module 'cv2.cv2' has no attribute 'cv2.MultiTracker_create()' 解决方 ...

  2. PythonPyQt5报错:AttributeError: module 'PyQt5.QtGui' has no attribute 'QMainWindow'

    在学习Python的PyQt5时,遇到了第一个问题:AttributeError: module 'PyQt5.QtGui' has no attribute 'QMainWindow' 代码如下 运 ...

  3. 解决AttributeError: module ‘scipy.misc‘ has no attribute ‘imread‘报错问题

    运行python程序报错:AttributeError: module 'scipy.misc' has no attribute 'imread' 报错原因1:scipy版本过高 解决方案:降低sc ...

  4. 报错与解决 | AttributeError: module ‘librosa.feature‘ has no attribute ‘rmse‘

    rmse → rms 代码:rmse = librosa.feature.rmse(y=y) 报错:AttributeError: module 'librosa.feature' has no at ...

  5. 完美解决AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm

    测试 import numpy as np import cv2 cap = cv2.VideoCapture('vtest.avi') fgbg = cv2.bgsegm.createBackgro ...

  6. 解决AttributeError: module ‘matplotlib.mlab‘ has no attribute ‘normpdf‘

    解决AttributeError: module 'matplotlib.mlab' has no attribute 'normpdf' 报错代码 y = mlab.normpdf(bins, mu ...

  7. 解决tensorflow报错:AttributeError: module ‘tensorflow.keras.backend‘ has no attribute ‘get_session‘ 问题

    欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 解决tensorflow报错:AttributeError: module 'tensorflow.keras.back ...

  8. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module ‘pip‘ has no attribute ‘main‘ 解决方法

    [pycharm]pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 参考文章: (1) ...

  9. TensorFlow报错:AttributeError: module 'tensorflow._api.v1.train' has no attribute 'SummaryWriter'等

    TensorFlow报错:AttributeError: module 'tensorflow._api.v1.train' has no attribute 'SummaryWriter'等 分析: ...

  10. 【报错】AttributeError: module ‘skimage‘ has no attribute ‘morphology‘

    瞎试了一通!解决方法真是令人震惊! 问题描述 import skimage没有问题,用skimage.morphology报错.AttributeError: module 'skimage' has ...

最新文章

  1. c语言删除偶数号节点,第十二周作业
  2. Nginx+Lua服务端合并静态文件
  3. 二十七、事务隔离级别示例
  4. 蚁群算法搜索个体适应度值
  5. Swing的设计是MVC的典范
  6. Confluence 6 管理协同编辑 - 关于 Synchrony
  7. vs2008使用技巧
  8. matplotlib之contours等高线、3D图(笔记五)
  9. [翻译 EF Core in Action 1.7] MyFirstEfCoreApp访问的数据库
  10. python搭建django环境_在BAE上搭建python,django环境小记
  11. MGRE、OSPF综合实验
  12. 计算机物联网软件工程,关于计算机物联网的应用分析
  13. 人工智能 机器学习 数据挖掘 数据分析 算法大全
  14. cmake编译错误,将警告视为错误的解决方法
  15. oracle脚本怎么跑,命令行执行oracle的sql脚本逃跑吧少年秒开钥匙下载最
  16. 【职场篇】游戏开发社招求职面试指南③——面试总结
  17. 【Windows】怎么查看CUDA版本?Conda命令安装和NVIDIA官网安装包安装的CUDA有何区别?nvcc -V和nvidia-smi获得的CUDA版本有何区别?如何指定CUDA版本?
  18. 不再追求安全感,你才能走向成熟。
  19. 360与腾讯的连横合纵
  20. Mysql8.x安装教程

热门文章

  1. 第二课.多元高斯分布与其几何特征
  2. Windows下有关NDK安装出现的问题的总结
  3. mysql 缓存区_Mysql缓存的配置和使用
  4. python异常处理语句编程题_一篇文章让你掌握Python异常处理所有知识点,记得收藏...
  5. 阿里云证书 | 套路太深,还是我打开姿势不对?
  6. EL:固氮能力主要取决于物种分类而不是土壤养分
  7. 来者不拒,“昊”课等你——直播微生物篇
  8. “我付了钱,为何要说谢谢?”
  9. 东北黑土区不同纬度农田土壤真菌分子生态网络的比较
  10. Nature:环境vs基因,谁对肠道菌群影响更大?