# direct show and CUDA

**URL:** <https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256>\
**Category:** CUDA Programming and Performance\
**Created:** [January 15, 2009, 10:49am UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256 "2009-01-15T10:49:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [January 15, 2009, 10:49am UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/1 "2009-01-15T10:49:50Z")

</div>

Hi,

I’m using CUDA in a static library. This library is either used by an executable, or by a Direct Show filter.

With the executable everything goes fine.  
With the filter, I can set the device, see its properties, allocate memory and transfer data to it, but it fails when it comes to cudaBindTextureToArray with “invalid texture reference”, cudaMemcpyToSymbol with “invalid device symbol”, and kernel launch with “invalid device function”.

The texture reference and the constant data (for which I call cudaMemcpyToSymbol ) are global variables.

Any sugestions, hints, ideas?  
Thanks, Bogdan

---

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [January 15, 2009, 1:05pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/2 "2009-01-15T13:05:34Z")

</div>

> [@](#):
>
> Hi,
> 
> I’m using CUDA in a static library. This library is either used by an executable, or by a Direct Show filter.
> 
> With the executable everything goes fine.
> 
> With the filter, I can set the device, see its properties, allocate memory and transfer data to it, but it fails when it comes to cudaBindTextureToArray with “invalid texture reference”, cudaMemcpyToSymbol with “invalid device symbol”, and kernel launch with “invalid device function”.
> 
> The texture reference and the constant data (for which I call cudaMemcpyToSymbol ) are global variables.
> 
> Any sugestions, hints, ideas?
> 
> Thanks, Bogdan

I’m using VC 7.1. .NET framework 1.1

---

<div class="post-metadata">

**Author:** ![Ailleur](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ailleur](https://forums.developer.nvidia.com/u/Ailleur)\
**Post date:** [January 15, 2009, 1:23pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/3 "2009-01-15T13:23:35Z")

</div>

The only time i received those errors was when trying to execute a code compiled with arch\_11 on a device not supporting it.

---

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [January 15, 2009, 1:36pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/4 "2009-01-15T13:36:58Z")

</div>

> [@](#):
>
> The only time i received those errors was when trying to execute a code compiled with arch\_11 on a device not supporting it.

I have a 260 gtx, and not using doubles at all.

---

<div class="post-metadata">

**Author:** ![cyrusvhadsupper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cyrusvhadsupper](https://forums.developer.nvidia.com/u/cyrusvhadsupper)\
**Post date:** [June 15, 2009, 8:16pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/5 "2009-06-15T20:16:37Z")

</div>

> [@](#):
>
> Hi,
> 
> I’m using CUDA in a static library. This library is either used by an executable, or by a Direct Show filter.
> 
> With the executable everything goes fine.
> 
> With the filter, I can set the device, see its properties, allocate memory and transfer data to it, but it fails when it comes to cudaBindTextureToArray with “invalid texture reference”, cudaMemcpyToSymbol with “invalid device symbol”, and kernel launch with “invalid device function”.
> 
> The texture reference and the constant data (for which I call cudaMemcpyToSymbol ) are global variables.
> 
> Any sugestions, hints, ideas?
> 
> Thanks, Bogdan

I’m having exactly the same problem!

I’m running with Visual Studio 2008, Windows XP SP3, CUDA 2.2

Sometimes I got “invalid argument”, other times I got “invalid device function” error. But the cuda code runs just fine with executables; just when embedded in a DirectShow filter that things went wrong

Any information on this would be much appreciated!

---

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [June 16, 2009, 2:02pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/6 "2009-06-16T14:02:31Z")

</div>

> [@](#):
>
> I’m having exactly the same problem!
> 
> I’m running with Visual Studio 2008, Windows XP SP3, CUDA 2.2
> 
> Sometimes I got “invalid argument”, other times I got “invalid device function” error. But the cuda code runs just fine with executables; just when embedded in a DirectShow filter that things went wrong
> 
> Any information on this would be much appreciated!

Could you try the MD version of cuda 2.2?(It can be downloaded in some thread over here). And it works with VS2008. I’m just curious if it changes anything.

---

<div class="post-metadata">

**Author:** ![cyrusvhadsupper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cyrusvhadsupper](https://forums.developer.nvidia.com/u/cyrusvhadsupper)\
**Post date:** [June 16, 2009, 5:10pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/7 "2009-06-16T17:10:31Z")

</div>

> [@](#):
>
> Could you try the MD version of cuda 2.2?(It can be downloaded in some thread over here). And it works with VS2008. I’m just curious if it changes anything.

Hi bog,

I’m going to try it out

yilei

---

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [June 17, 2009, 4:56pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/8 "2009-06-17T16:56:14Z")

</div>

> [@](#):
>
> Hi bog,
> 
> I’m going to try it out
> 
> yilei

I tried it, and made no difference in my case.

I thought that could be a cause, because my library is compiled with “MD”

It seems that CUDA and Direct Show are not very happy together!?

Also checked that it was the same thread for all cuda calls.

---

<div class="post-metadata">

**Author:** ![cyrusvhadsupper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cyrusvhadsupper](https://forums.developer.nvidia.com/u/cyrusvhadsupper)\
**Post date:** [June 19, 2009, 10:19pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/9 "2009-06-19T22:19:27Z")

</div>

> [@](#):
>
> I tried it, and made no difference in my case.
> 
> I thought that could be a cause, because my library is compiled with “MD”
> 
> It seems that CUDA and Direct Show are not very happy together!?
> 
> Also checked that it was the same thread for all cuda calls.

Hi bog,

I had the chance to try out my program today, and it is working… CUDA is running just fine.

Some differences in the program from last time I got my “invalid device function” or whatever error:

1. I was using visual studio 2008 **express** edition, windows sdk 6.1, cuda 2.2, windows xp professional;

2. Previously, in my DirectShow filter, I have a internal capture graph which consists of CaptureSource(Webcam)-\>SampleGraber-\>NullRenderer;

I’m using /MT for CUDA compilation and /MD for C++ compilation, just as before; haven’t even switched to /MD for CUDA yet and it is already working.

So, either 1 or 2 fixes the problem; I don’t have the proper hardware device at hand to make a verdict, so will try out later and update you.

BR,

Yilei

---

<div class="post-metadata">

**Author:** ![bog](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bog](https://forums.developer.nvidia.com/u/bog)\
**Post date:** [June 22, 2009, 1:07pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/10 "2009-06-22T13:07:14Z")

</div>

> [@](#):
>
> Hi bog,
> 
> I had the chance to try out my program today, and it is working… CUDA is running just fine.
> 
> Some differences in the program from last time I got my “invalid device function” or whatever error:
> 
> 1. I was using visual studio 2008 **express** edition, windows sdk 6.1, cuda 2.2, windows xp professional;
> 
> 2. Previously, in my DirectShow filter, I have a internal capture graph which consists of CaptureSource(Webcam)-\>SampleGraber-\>NullRenderer;
> 
> I’m using /MT for CUDA compilation and /MD for C++ compilation, just as before; haven’t even switched to /MD for CUDA yet and it is already working.
> 
> So, either 1 or 2 fixes the problem; I don’t have the proper hardware device at hand to make a verdict, so will try out later and update you.
> 
> BR,
> 
> Yilei

Hi Yilei,

I’m using VS2005 professional edition, 32 bit xp. The graph includes a video decoder and then video encoder. (Maybe if I read a decoded source from disk, it will work)

---

<div class="post-metadata">

**Author:** ![cyrusvhadsupper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cyrusvhadsupper](https://forums.developer.nvidia.com/u/cyrusvhadsupper)\
**Post date:** [June 25, 2009, 8:22pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/11 "2009-06-25T20:22:34Z")

</div>

> [@](#):
>
> Hi Yilei,
> 
> I’m using VS2005 professional edition, 32 bit xp. The graph includes a video decoder and then video encoder. (Maybe if I read a decoded source from disk, it will work)

Hi bog,

I’ve been playing around on two computers, one with x64 win xp / vs 2008 pro, the other with x32 win xp / vs 2008 express; they are located in different places without proper remote access method, so it took me a while to find things out…

Remember last time I talked about getting rid of the internal graph, streaming video frame from local harddisk rather than from webcam, and all these might be the reason of the fact that “invalid device function” is gone. But it is not.

The sole difference between a working project and the one giving “invalid device function” error is this, at least for me:

```
Project -> Properties -> Linker -> Advanced -> Entry Point. In the working project I leave it blank, and in the erroneous one I have DllEntryPoint

```

I guess ultimately it is calling CUDA code within a dll that is making things ugly.

Really appreciate if someone has an explanation for this… Really lucky to find this glitch while trial-and-error…

Yilei

---

<div class="post-metadata">

**Author:** ![cyrusvhadsupper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@cyrusvhadsupper](https://forums.developer.nvidia.com/u/cyrusvhadsupper)\
**Post date:** [June 25, 2009, 9:52pm UTC](https://forums.developer.nvidia.com/t/direct-show-and-cuda/7256/12 "2009-06-25T21:52:52Z")

</div>

> [@](#):
>
> Hi bog,
> 
> I’ve been playing around on two computers, one with x64 win xp / vs 2008 pro, the other with x32 win xp / vs 2008 express; they are located in different places without proper remote access method, so it took me a while to find things out…
> 
> Remember last time I talked about getting rid of the internal graph, streaming video frame from local harddisk rather than from webcam, and all these might be the reason of the fact that “invalid device function” is gone. But it is not.
> 
> The sole difference between a working project and the one giving “invalid device function” error is this, at least for me:
> 
> ```
> Project -> Properties -> Linker -> Advanced -> Entry Point. In the working project I leave it blank, and in the erroneous one I have DllEntryPoint
> 
> ```
> 
> I guess ultimately it is calling CUDA code within a dll that is making things ugly.
> 
> Really appreciate if someone has an explanation for this… Really lucky to find this glitch while trial-and-error…
> 
> Yilei

http://msdn.microsoft.com/en-us/library/f9t8842e(VS.71).aspx

It states: “It is recommended that you let the linker set the entry point so that the C run-time library is initialized correctly, and C++ constructors for static objects are executed.”

Manually setting Entry Point to DllEntryPoint triggers the “invalid device function” error; maybe CUDA initialization is not fully completed after all, even though memcpy works?
