Skip to content

failed to query current context: CUDA_ERROR_DEINITIALIZED #713

Closed

Description

@wchan

This is a regression problem, code was working fine 2 wks ago, did a git sync to the head and now I have this log message:

I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcublas.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcudnn.so.6.5 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcufft.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcuda.so locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcurand.so.7.0 locally
I tensorflow/core/common_runtime/gpu/gpu_init.cc:103] Found device 0 with properties:
name: GeForce GTX TITAN X
major: 5 minor: 2 memoryClockRate (GHz) 1.076
pciBusID 0000:02:00.0
Total memory: 12.00GiB
Free memory: 11.87GiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:127] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_init.cc:137] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:705] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:02:00.0)
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:42] Allocating 11.27GiB bytes.
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:52] GPU 0 memory begins at 0x2306c80000 extends to 0x25d8436a67
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 1.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 2.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 4.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 8.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 16.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 32.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 64.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 128.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 256.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 512.0KiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 1.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 2.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 4.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 8.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 16.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 32.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 64.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 128.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 256.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 512.00MiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 1.00GiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 2.00GiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 4.00GiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 8.00GiB
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:66] Creating bin of max chunk size 16.00GiB
create_encoder graph time 0.569116
create_decoder graph time 2.629546
create_loss graph time 0.960969
create_optimizer graph time 34.311540
F tensorflow/stream_executor/cuda/cuda_driver.cc:299] failed to query current context: CUDA_ERROR_DEINITIALIZED
F tensorflow/stream_executor/cuda/cuda_driver.cc:299] failed to query current context: CUDA_ERROR_DEINITIALIZED
F tensorflow/stream_executor/cuda/cuda_driver.cc:299] failed to query current context: CUDA_ERROR_DEINITIALIZED
F tensorflow/stream_executor/cuda/cuda_driver.cc:408] Check failed: CUDA_SUCCESS == dynload::cuCtxSetCurrent(prior_context_) (0 vs. 4)
Aborted (core dumped)

Note: (the create_*) is my code creating the graph.
The python code it crashes on is:
sess.run(tf.initialize_all_variables())

Activity

  1. wchan commented on Jan 7, 2016

    @wchan
    Author

    here's the stack trace from gdb:

    #2 0x00007fff52e11ad4 in tensorflow::internal::LogMessageFatal::~LogMessageFatal() () from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.so
    #3 0x00007fff52de0ff3 in perftools::gputools::cuda::(anonymous namespace)::CurrentContext() () from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.so
    #4 0x00007fff52de130c in perftools::gputools::cuda::ScopedActivateContext::ScopedActivateContext(CUctx_st
    , perftools::gputools::cuda::MultiOpActivation) ()
    from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.so
    #5 0x00007fff52da145a in perftools::gputools::cuda::ScopedActivateExecutorContext::ScopedActivateExecutorContext(perftools::gputools::cuda::CUDAExecutor
    , perftools::gputools::cuda::MultiOpActivation) ()
    from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.so
    #6 0x00007fff52c2e3e7 in tensorflow::BaseGPUDevice::Compute(tensorflow::OpKernel
    , tensorflow::OpKernelContext
    ) () from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
    #7 0x00007fff52c4eac8 in tensorflow::(anonymous namespace)::ExecutorState::Process(tensorflow::(anonymous namespace)::ExecutorState::TaggedNode, long long) ()
    from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
    #8 0x00007fff52c43d20 in std::_Function_handler<void (), std::_Bind<std::_Mem_fn<void (tensorflow::(anonymous namespace)::ExecutorState::)(tensorflow::(anonymous namespace)::ExecutorState::TaggedNode, long long)> (tensorflow::(anonymous namespace)::ExecutorState, tensorflow::(anonymous namespace)::ExecutorState::TaggedNode, long long)> >::_M_invoke(std::_Any_data const&) ()
    from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
    #9 0x00007fff52dff357 in tensorflow::thread::ThreadPool::WorkerLoop() () from /data-local/wchan/tensorflow_env/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
    #10 0x00007ffff436ea40 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #11 0x00007ffff7bc4182 in start_thread (arg=0x7ffef87f8700) at pthread_create.c:312
    #12 0x00007ffff78f147d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

  2. skearnes commented on Jan 7, 2016

    @skearnes

    +1

  3. alexatknit commented on Jan 7, 2016

    @alexatknit

    I've got the same issue

  4. vrv commented on Jan 7, 2016

    @vrv

    I have a suspicion that our mega-commit 1c57936 might have introduced a change that broke this (there are a bunch of changes that could be responsible, including changes to the stream executor and updating to a new version of Eigen, among other things).

    It would be great if someone could confirm if it works at 2956250 but fails at the commit right after.

  5. skearnes commented on Jan 7, 2016

    @skearnes

    @vrv 2956250 works for me; 1c57936 does not.

  6. vrv commented on Jan 7, 2016

    @vrv

    Cool, thanks for verifying. If you have time:

    Revert the WORKSPACE file and eigen.BUILD changes (to use an earlier version of Eigen) and see if the problem goes away.

    I'll dig into potential other issues in that commit.

  7. skearnes commented on Jan 7, 2016

    @skearnes

    Checking out WORKSPACE and eigen.BUILD from 2956250 does not fix the problem.

  8. vrv commented on Jan 7, 2016

    @vrv

    Ok thanks, that helps.

  9. vrv commented on Jan 7, 2016

    @vrv

    @zheng-xq, who independently was trying to debug this.

  10. alexatknit commented on Jan 7, 2016

    @alexatknit

    I reverted to 2956250 and it seems to work, but the execution speed is cut in half

  11. vrv commented on Jan 7, 2016

    @vrv

    Yup, that commit improved speed for some models, @zheng-xq is looking into what broke it.

  12. zheng-xq commented on Jan 8, 2016

    @zheng-xq
    Contributor

    I can confirm that with eigen-a0661a2bb165, an Eigen kernel fails to
    launch. But with the older eigen-ce5a455b34c0, this problem goes away.

    My reproducing command line:

    bazel run -c opt --config=cuda
    //tensorflow/models/image/alexnet:alexnet_benchmark

    Passing to @benoitsteiner

    On Thu, Jan 7, 2016 at 11:18 AM, Martin Wicke [email protected]
    wrote:

    Assigned #713 #713 to
    @zheng-xq https://github.com/zheng-xq.

    —
    Reply to this email directly or view it on GitHub
    #713 (comment).

  13. vrv commented on Jan 8, 2016

    @vrv

    @zheng-xq: what eigen kernel failed, so we can figure out which kernel was the problem?

  14. zheng-xq commented on Jan 8, 2016

    @zheng-xq
    Contributor

    The kernel that was causing problem is:

    EigenMetaKernel_Vectorizable<Eigen::TensorEvaluator<Eigen::TensorAssignOp<Eigen::TensorMap<Eigen::Tensor<float,
    1, 1, int>, 16>,
    Eigen::TensorCwiseUnaryOp<Eigen::internal::scalar_right<float, float,
    Eigen::internal::scalar_product_op<float, float>, true>,
    Eigen::TensorMap<Eigen::Tensor<float const, 1, 1, int>, 16> const> const>
    const, Eigen::GpuDevice>, int>

    It came from cwise_mul:

    tensorflow::BinaryOp<Eigen::GpuDevice, tensorflow::functor::mul >

    On Thu, Jan 7, 2016 at 6:53 PM, Vijay Vasudevan [email protected]
    wrote:

    @zheng-xq https://github.com/zheng-xq: what eigen kernel failed, so we
    can figure out which kernel was the problem?

    —
    Reply to this email directly or view it on GitHub
    #713 (comment)
    .

  15. benoitsteiner commented on Jan 8, 2016

    @benoitsteiner
    Contributor

    When running "bazel-bin/tensorflow/models/image/alexnet/alexnet_benchmark --benchmarks=all" on my machine, I get the following error:
    external/re2/re2/regexp.cc:136: Bad reference count 65535
    F tensorflow/stream_executor/cuda/cuda_driver.cc:408] Check failed: CUDA_SUCCESS == dynload::cuCtxSetCurrent(prior_context_) (0 vs. 4)

  16. vrv commented on Jan 9, 2016

    @vrv

    Okay, we rolled back the change to switch to the newer version of Eigen, which apparently had some issues. 22267ad

    So things should be now be working.

    However, this uses an older version of Eigen that has some speed problems.

    @benoitsteiner has upstreamed a newer fix to Eigen which should bring back the speed improvements and not crash things, so look for that soon.

    Closing this for now, let us know if you still see problems.

  17. jeremybarnes commented on Jan 10, 2016

    @jeremybarnes

    FWIW, I spent some time independently debugging this issue as well. What I found was that the preprocessor magic in Eigen was removing nvcc's ability to know what templated kernels to instantiate for the device code. The fix for the non-convolutional kernels was to modify the eigen/unsupported/CXX11/src/tensor/TensorDeviceCuda.h file and modify the LAUNCH_CUDA_KERNEL macro for the device code to force instantiation of the kernel.

    The full patch and details are in the Bitbucket pull request:

    https://bitbucket.org/eigen/eigen/pull-requests/152/alternative-way-of-forcing-instantiation/diff

    #ifndef __CUDA_ARCH__
    #define LAUNCH_CUDA_KERNEL(kernel, gridsize, blocksize, sharedmem, device, ...)            \
        (kernel) <<< (gridsize), (blocksize), (sharedmem), (device).stream() >>> (__VA_ARGS__); \
        assert(cudaGetLastError() == cudaSuccess);
    #else
    #define LAUNCH_CUDA_KERNEL(kernel, ...)  \
        { static const auto __attribute__((__unused__)) __makeTheKernelInstantiate = &(kernel); } \
       eigen_assert(false && "Cannot launch a kernel from another kernel");
    #endif
    
  18. added and removed on Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions