0

I'm running the following code:

cuCtxCreate(&context, CU_CTX_SCHED_YIELD, device);

int driverVersion = -1;
int driverVersionRt = -1;
int rtVersion = -1;
unsigned int ctxVersion = 1;

cuDriverGetVersion(&driverVersion);
cudaDriverGetVersion(&driverVersionRt);
cudaRuntimeGetVersion(&rtVersion);
cuCtxGetApiVersion(context, &ctxVersion);

std::cout << "cuDriverGetVersion: " << driverVersion << std::endl;
std::cout << "cudaDriverGetVersion: " << driverVersionRt << std::endl;
std::cout << "cudaRuntimeGetVersion: " << rtVersion << std::endl;
std::cout << "cuCtxGetApiVersion: " << ctxVersion << std::endl;

Here is the output:

cuDriverGetVersion: 10010
cudaDriverGetVersion: 10010
cudaRuntimeGetVersion: 10000
cuCtxGetApiVersion: 3020

From the documentation, I can see that cudaDriverGetVersion, cuDriverGetVersion, and cudaRuntimeGetVersion return values of the form (1000 * major + 10 * minor). The documentation does not specify what cuCtxGetApiVersion should return, but I assume it should be the same as the other three functions.

My question is why is the version number for the context 3020, when all the others are using 10000 and 10010? Is this how it should be?

I am having another issue where new threads that I create need to have their context shared manually, otherwise I get a 201 (invalid context) error. This is strange because I know past CUDA 4.0 all processes have one context per device per process. So I should not have to set the context for new threads that I am creating within the same process. Because cuCtxGetApiVersion is producing 3020, this leads me to believe that the context I created is using an old incorrect version, which would not have the functionality of being shared across threads.

Is this a possibility?

4

1 回答 1

0

It turns out that the cuCtxGetApiVersion was working correctly.

This answer helped me understand what was going on. My cuCtxGetApiVersion was using the "v2". The context version is an up to date one even though it looks to be old.

As for my second question, I found that the behavior I was getting was to be expected. Previously I was passing in streams to perform asynchronous calls, but I had played around with synchronous calls where no stream is specified. New threads that got created would not have the context associated with them.

于 2019-04-08T17:30:46.817 回答