【pycuda】——pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no

5 篇文章 0 订阅

转载自:https://blog.csdn.net/weixin_34910922/article/details/109906628

报错:

pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no currently active context?

原因:
pycuda.driver没有初始化,导致无法得到context,需要在导入pycuda.driver后再导入pycuda.autoinit,即如下:

import pycuda.driver as cuda
import pycuda.autoinit
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
========= Cppcheck ========= About The original name of this program is "C++check" but it was later changed to "cppcheck". Manual A manual is available online: http://cppcheck.sourceforge.net/manual.pdf Compiling Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2010 then it will work. If nullptr is not supported by your compiler then this can be emulated using the header lib/cxx11emu.h. To build the GUI, you need Qt. When building the command line tool, PCRE is optional. It is used if you build with rules. There are multiple compilation choices: * qmake - cross platform build tool * cmake - cross platform build tool * Windows: Visual Studio * Windows: Qt Creator + mingw * gnu make * g++ 4.6 (or later) * clang++ qmake ===== You can use the gui/gui.pro file to build the GUI. cd gui qmake make Visual Studio ============= Use the cppcheck.sln file. The file is configured for Visual Studio 2013, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64. To compile with rules, select "Release-PCRE" or "Debug-PCRE" configuration. pcre.lib (pcre64.lib for x64 builds) and pcre.h are expected to be in /extlibs then. Qt Creator + mingw ================== The PCRE dll is needed to build the CLI. It can be downloaded here: http://software-download.name/pcre-library-windows/ gnu make ======== Simple build (no dependencies): make The recommended release build is: make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes Flags: SRCDIR=build : Python is used to optimise cppcheck CFGDIR=cfg : Specify folder where .cfg files are found HAVE_RULES=yes : Enable rules (pcre is required if this is used) g++ (for experts) ================= If you just want to build Cppcheck without dependencies then you can use this command: g++ -o cppcheck -std=c++0x -include lib/cxx11emu.h -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/tinyxml/*.cpp If you want to use --rule and --rule-file then dependencies are needed: g++ -o cppcheck -std=c++0x -include lib/cxx11emu.h -lpcre -DHAVE_RULES -Ilib -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/tinyxml/*.cpp mingw ===== The "LDFLAGS=-lshlwapi" is needed when building with mingw mingw32-make LDFLAGS=-lshlwapi other compilers/ide =================== 1. Create a empty project file / makefile. 2. Add all cpp files in the cppcheck cli and lib folders to the project file / makefile. 3. Compile. Cross compiling Win32 (CLI) version of Cppcheck in Linux sudo apt-get install mingw32 make CXX=i586-mingw32msvc-g++ LDFLAGS="-lshlwapi" mv cppcheck cppcheck.exe Webpage http://cppcheck.sourceforge.net/
针第一个问题,您遇到的错误是'AttributeError: module 'tensorflow.compat.v1' has no attribute 'contrib''。这个错误通常是由于您使用的TensorFlow版本不兼容导致的。在较新的TensorFlow版本中,'contrib'模块已被移除,所以您无法使用它。要解决这个问题,您可以尝试以下几种方法: 1. 检查您的TensorFlow版本是否较新。您可以使用命令"pip show tensorflow"查看您当前安装的TensorFlow版本。如果您的版本较新,请尝试降级到较旧的版本,或者更新您的代码以适应新版TensorFlow。 2. 如果您的代码依赖于'contrib'模块中的特定功能,您可以尝试使用其他替代方法来实现相同的功能。查看TensorFlow的官方文档和社区论坛,寻找替代方法或建议。 3. 如果您只是想消除警告信息,您可以尝试在代码的开头添加以下行:import tensorflow.compat.v1 as tf tf.disable_v2_behavior()。这将启用TensorFlow的兼容性模式,以便您可以继续使用旧版的'contrib'模块。 针对第二个问题,您遇到的错误是'AttributeError: 'module' object has no attribute 'scalar_summary''。这个错误通常是由于您使用的TensorFlow版本不兼容导致的。在较新的版本中,'scalar_summary'已被废弃,取而代之的是'tf.summary.scalar'。要解决这个问题,您可以尝试修改代码中的'tf.scalar_summary'为'tf.summary.scalar'。 针对第三个问题,您遇到的错误是'AttributeError: 'module' object has no attribute 'merge_all_summaries''。同样地,这个错误通常是由于TensorFlow版本不兼容而导致的。在较新的版本中,'merge_all_summaries'已被废弃,取而代之的是'tf.summary.merge_all'。您需要将代码中的'tf.merge_all_summaries'修改为'tf.summary.merge_all'。 关于您的补充问题,'AttributeError: module 'tensorflow.python._pywrap_tensorflow_internal' has no attribute 'TFE_DEVICE_PLACEMENT_EXPLICIT''。根据错误信息,它表明您正在尝试访问名为'TFE_DEVICE_PLACEMENT_EXPLICIT'的属性,但该属性在您使用的TensorFlow模块中不存在。可能的原因是您正在使用的TensorFlow版本不支持此属性,或者您没有正确导入或设置相应的模块。您可以尝试检查您的TensorFlow版本以及导入和设置相关模块的正确性。如果问题仍然存在,请尝试在TensorFlow的官方文档和社区论坛中寻找相关解决方案或建议。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值