Runtime error using nvc++ under wsl2

I’m interested in using stdpar as documented here. I have a very small test code which compiles under WSL2, but I get a runtime error: libcuda routine cuDevicePrimaryCtxGetState not loaded, exiting.

I’m using driver version 511.65 and nvhpc 22.2 and am willing to provide any additional information that might prove useful. Does anybody know why I’m getting this error?

Entire test code:

#include<algorithm>
#include<cassert>
#include<execution>
#include<functional>
#include<vector>

int main(int argc, char* argv[]) {
    using std::execution::par_unseq;
    using std::vector;

    const int n = 1e8;
    vector<double> x(n), y(n), z(n);

    // Initialize x and y
    for(int i=0; i<n; i++) {
        x[i] = i;
        y[i] = n-i;
    }

    // Compute sum of x and y
    std::transform(par_unseq, x.cbegin(), x.cend(), y.cbegin(),
                   z.begin(), std::plus<>{});

    // Assert that the sum is correct
    for(int i=0; i<n; i++) {
        assert(z[i] == n);
    }

    return 0;
}

Hi aklinvex,

I tried your program on my laptop where it worked fine. Though I did have to lower the value of “n” due to memory constraints on my system.

What is the output from the commands “nvaccelinfo” and “nvidia-smi”?
Are you able to run a simple CUDA code?

Now my driver is different from yours (425.31) and I’m not familiar with the Studio Drivers. While I would assume the Studio drivers would still work with WSL, I’m not sure. Maybe running “wsl.exe --update” from a power shell to see if WSL needs an update?

-Mat