# Internal Memcheck Error: Initialization failed

**URL:** <https://forums.developer.nvidia.com/t/internal-memcheck-error-initialization-failed/184907>\
**Category:** CUDA-MEMCHECK\
**Created:** [July 28, 2021, 2:48am UTC](https://forums.developer.nvidia.com/t/internal-memcheck-error-initialization-failed/184907 "2021-07-28T02:48:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacek.tomaka](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jacek.tomaka](https://forums.developer.nvidia.com/u/jacek.tomaka)\
**Post date:** [July 28, 2021, 2:48am UTC](https://forums.developer.nvidia.com/t/internal-memcheck-error-initialization-failed/184907/1 "2021-07-28T02:48:52Z")

</div>

Hello,  
Is there a way to make memcheck tell me more about its error?  
I am getting just this:

```auto
========= Internal Memcheck Error: Initialization failed
========= Saved host backtrace up to driver entry point at error
========= Host Frame:/lib64/libcuda.so.1 [0x205cfb]
========= Host Frame:/my/shared/object.so [0x7dd524]
========= Host Frame:/my/shared/object.so [0x7d244e]
========= Host Frame:/my/shared/object.so [0x7e3c44]
========= Host Frame:/my/shared/object.so [0x7e840a]
========= Host Frame:/my/shared/object.so [0x7e86a4]
========= Host Frame:/my/shared/object.so [0x7da5ec]
========= Host Frame:/my/shared/object.so [0x7c3953]
========= Host Frame:/my/shared/object.so [0x7fa8bc]
========= Host Frame:/my/shared/object.so [0x52cbdc]
========= Host Frame:/my/shared/object.so (getMicMemoryBytes + 0x4a) [0x52cde8]
========= Host Frame:[0x2ae640494990]
=========

```

And the getMicMemoryBytes just something like:  
static long cuda\_get\_device\_memory(int device) {  
size\_t free\_mem, total\_mem;  
cudaSetDevice(device);  
cudaMemGetInfo(&free\_mem, &total\_mem);  
return (long)total\_mem;  
}

The shared object is compiled using -G.

---

<div class="post-metadata">

**Author:** ![jacek.tomaka](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jacek.tomaka](https://forums.developer.nvidia.com/u/jacek.tomaka)\
**Post date:** [July 28, 2021, 3:45am UTC](https://forums.developer.nvidia.com/t/internal-memcheck-error-initialization-failed/184907/2 "2021-07-28T03:45:44Z")

</div>

I think i have figured it out. The first thing i do is cudaDeviceReset and this is the problem. I have moved cudaDeviceReset to when i am done with cuda and it does not have this problem.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [September 27, 2021, 1:06pm UTC](https://forums.developer.nvidia.com/t/internal-memcheck-error-initialization-failed/184907/3 "2021-09-27T13:06:47Z")

</div>

Closed on September 27, 2021, 1:06pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
