I may try later. For now, the problem has been fixed by manually creating a 
context and passing that to each function so that it can be used in `Thread`. I 
also pop() the context manually. Strangely, I just used pycuda.autoinit.context 
before, which should work in my opinion. Maybe it's an issue with 
pycuda.autoinit being imported several times or somethin?

Anyway, I appreciate your quick responses and helpfulness.

> On 31. Jul 2018, at 12:27, Bogdan Opanchuk <bog...@opanchuk.net> wrote:
> 
> Well, that's strange then. As far as I understand, scikit-cuda uses the 
> existing context (unless explicitly asked to create a new one), and Reikna 
> should too if you pass it the reference from pycuda.autoinit. I guess I can't 
> say anything more definite without seeing the code. Any change you can reduce 
> it to a shareable size while preserving the errors?
> 
> On Tue, Jul 31, 2018 at 6:05 PM, Rasmus Diederichsen 
> <rasmusdiederich...@gmail.com <mailto:rasmusdiederich...@gmail.com>> wrote:
> I do aim to use only one context (I don't know why I would want more than 
> one; the stuff I'm doing is mostly serial but the memory shouldn't leave the 
> GPU).
> 
>> On 31. Jul 2018, at 09:16, Bogdan Opanchuk <bog...@opanchuk.net 
>> <mailto:bog...@opanchuk.net>> wrote:
>> 
>> First of all, are you using multiple contexts or a single one? If you only 
>> have one context, `Thread(pycuda.autoinit.context)` should be enough for 
>> Reikna (don't know about scikit-cuda, though).
>> 
>> Now if you have several contexts, things become more complicated. CUDA 
>> maintains a global context stack, if you want to use a specific context, you 
>> have to make sure it is on top of the stack (using corresponding PyCUDA 
>> functions). For Reikna, you must use a `Thread` object created for a 
>> specific context (or anything derived from it) only when that context is 
>> active.
>> 
>> On Tue, Jul 31, 2018 at 5:07 PM, Rasmus Diederichsen 
>> <rasmusdiederich...@gmail.com <mailto:rasmusdiederich...@gmail.com>> wrote:
>> I don't know cuda really and use the 3 libraries mentioned in the subject. I 
>> time and again run into CUDA errors of the form "Invalid resource handle" 
>> which appear in some cases, but not in others, i.e. the same function will 
>> error or not depending on what ran before it, even if totally unrelated. I 
>> gather from this that it has to do with state in CUDA, possibly mismanaging 
>> contexts. But since it's hard to reproduce without all my code, I can't open 
>> issues about this, so hopefully someone can just give me general pointers.
>> 
>> I am using the `pycuda.autoinit.context` for all the Reikna `Thread`s.
>> Neither reikna nor scikit-cuda seem to have functionality for setting 
>> context globally or passing it to functions
>> I have tried using my own context instead, but meet the same issues
>> 
>> What are the steps in general to ensure these issues don't come up? How can 
>> I handle this when multiple files are in play?
>> 
>> Cheers,
>> Rasmus
>> 
>> _______________________________________________
>> PyCUDA mailing list
>> PyCUDA@tiker.net <mailto:PyCUDA@tiker.net>
>> https://lists.tiker.net/listinfo/pycuda 
>> <https://lists.tiker.net/listinfo/pycuda>
>> 
>> 
> 
> 

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
https://lists.tiker.net/listinfo/pycuda

Reply via email to