# Error: CUDANoDevice on WSL

**URL:** <https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772>\
**Category:** Errors\
**Created:** [15 March 2023 11:11 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772 "2023-03-15T11:11:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 11:11 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/1 "2023-03-15T11:11:06Z")

</div>

Hello,  
I installed PyFR following this page ,ubuntu ([Installation — Documentation](https://pyfr.readthedocs.io/en/latest/installation.html#))  
I am tyring test cases on wrb site([Examples — Documentation](https://pyfr.readthedocs.io/en/latest/examples.html)). I could make one partation, however I have gotten error mesages. Could you tell me how to fix it? My cuda version is 12.0 and pyhon is 3.10.6.  
I attach the error mesages.  
Best,  
Yuji

 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/e19d88111a80dc043d6a1886ffe45cb76cde9db7.png)

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [15 March 2023 11:32 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/2 "2023-03-15T11:32:34Z")

</div>

Did you add anything to the ini file regarding the cuda backend? For example:

```ini
[backend-cuda]
device-id = local-rank

```

Also when you run `nvidia-smi` do you see the GPU?

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 12:03 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/3 "2023-03-15T12:03:56Z")

</div>

Thank you for replying.  
Yes, I can watch GPU.

 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/92b3f98f5355e90380fa2a9017c64549fe329ea7.png)

I did not add anything into the ini file. Where should I write?

```ini
[backend]
precision = double

[constants]
nu = 0.005
Uin = 1.0
Vin = 0.0
Pc = 1.0
ac-zeta = 2.5

[solver]
system = ac-navier-stokes
order = 3

[solver-time-integrator]
formulation = dual
scheme = sdirk33
pseudo-scheme = rk45
controller = none
pseudo-controller = local-pi
tstart = 0.0
tend = 75.0
dt = 0.05
pseudo-dt = 0.005
pseudo-niters-min = 3
pseudo-niters-max = 3
pseudo-resid-norm = l2
pseudo-resid-tol = 1e-12
atol = 1e-6
pseudo-dt-max-mult = 2.5

[solver-dual-time-integrator-multip]
pseudo-dt-fact = 1.75
cycle = [(3, 1), (2, 1), (1, 1), (0, 2), (1, 1), (2, 1), (3, 4)]

[solver-interfaces]
riemann-solver = rusanov
ldg-beta = 0.5
ldg-tau = 0.1

[solver-interfaces-line]
flux-pts = gauss-legendre

[solver-elements-tri]
soln-pts = williams-shunn

[solver-elements-quad]
soln-pts = gauss-legendre

[soln-plugin-nancheck]
nsteps = 50

[soln-plugin-pseudostats]
flushsteps = 20
file = residual.csv
header = true

[soln-plugin-writer]
dt-out = 5.0
basedir = .
basename = inc-cylinder-{t:.2f}

[soln-bcs-wall]
type = no-slp-wall

[soln-bcs-inlet]
type = ac-char-riem-inv
ac-zeta = 180
p = Pc
u = Uin
v = Vin

[soln-bcs-outlet]
type = ac-char-riem-inv
ac-zeta = 180
p = Pc
u = Uin
v = Vin

[soln-ics]
u = Uin
v = Vin
p = Pc

```

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [15 March 2023 12:13 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/4 "2023-03-15T12:13:03Z")

</div>

You can add it anywhere just not in the middle of some other seciton, the parser will find it. Under the hood this is what is being used: [configparser — Configuration file parser — Python 3.11.2 documentation](https://docs.python.org/3/library/configparser.html)

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 12:28 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/5 "2023-03-15T12:28:06Z")

</div>

I added the command. But I got same error messages.  
By the way, I updated CUDA 12.0 to 12.1

 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/afd67dc4d50ea54df1c2a12946bbd74b28588da8.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/f094da19d3969aa9ad1bec8dbb2748b2f2963c42.png)

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [15 March 2023 12:35 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/6 "2023-03-15T12:35:32Z")

</div>

When you updated cuda did you correctly update the library paths?

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 12:47 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/7 "2023-03-15T12:47:09Z")

</div>

Yes, I think I updated the library paths crrectly.  
Do you think that paths in my attached fig are correcte?

 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/8a14dea8034e6e5b194efb8b55794c5c574bc886.jpeg)

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 12:53 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/8 "2023-03-15T12:53:15Z")

</div>

I tried a sample code of Nvidia.  
I could calculate it.

![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/6e81deb4ae73ee1877f6654f22368fe3bcb3a3a3.png)

```c++
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <stdio.h>

cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);

__global__ void addKernel(int *c, const int *a, const int *b)
{
    int i = threadIdx.x;
    c[i] = a[i] + b[i];
}

int main()
{
    const int arraySize = 5;
    const int a[arraySize] = { 1, 2, 3, 4, 5 };
    const int b[arraySize] = { 10, 20, 30, 40, 50 };
    int c[arraySize] = { 0 };

    // Add vectors in parallel.
    cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "addWithCuda failed!");
        return 1;
    }

    printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n",
        c[0], c[1], c[2], c[3], c[4]);

    // cudaDeviceReset must be called before exiting in order for profiling and
    // tracing tools such as Nsight and Visual Profiler to show complete traces.
    cudaStatus = cudaDeviceReset();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaDeviceReset failed!");
        return 1;
    }

    return 0;
}

// Helper function for using CUDA to add vectors in parallel.
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size)
{
    int *dev_a = 0;
    int *dev_b = 0;
    int *dev_c = 0;
    cudaError_t cudaStatus;

    // Choose which GPU to run on, change this on a multi-GPU system.
    cudaStatus = cudaSetDevice(0);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?");
        goto Error;
    }

    // Allocate GPU buffers for three vectors (two input, one output) .
    cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    // Copy input vectors from host memory to GPU buffers.
    cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

    cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

    // Launch a kernel on the GPU with one thread for each element.
    addKernel<<<1, size>>>(dev_c, dev_a, dev_b);

    // Check for any errors launching the kernel
    cudaStatus = cudaGetLastError();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
        goto Error;
    }

    // cudaDeviceSynchronize waits for the kernel to finish, and returns
    // any errors encountered during the launch.
    cudaStatus = cudaDeviceSynchronize();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
        goto Error;
    }

    // Copy output vector from GPU buffer to host memory.
    cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

Error:
    cudaFree(dev_c);
    cudaFree(dev_a);
    cudaFree(dev_b);

    return cudaStatus;
}

```

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [15 March 2023 13:28 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/9 "2023-03-15T13:28:37Z")

</div>

I use Ubuntu 22.04  
Dose it have relationship with this error?

 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/83bd2f754ad779910086154ef1b1ccbad0feda6b.png)

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [15 March 2023 15:49 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/10 "2023-03-15T15:49:22Z")

</div>

There might be something else in the software stack that is compiled against the old version of cuda. Have you recompiled everything against this new version of cuda that might be using it?

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [16 March 2023 03:32 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/11 "2023-03-16T03:32:02Z")

</div>

Thank you for your replyig.  
I will fresh my wsl ubuntu and reinstall.

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [16 March 2023 14:24 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/12 "2023-03-16T14:24:39Z")

</div>

Be sure to follow the CUDA on WSL install guide to the letter. Otherwise, it is easy to end up with two copies of `libcuda.so` and one of them will be broken.

Regards, Freddie.

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [17 March 2023 04:12 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/13 "2023-03-17T04:12:43Z")

</div>

Dear Dr. Will , Prof Freddie,

Thank you for your replyng. I am done with calculating the test case on WSL with CUDA12.1  
I leave notes for anybady who has as same errors as I got on WSL with CUDA 12.1.

1. Installing the GPU driver in Windows automatically puts the driver in the WSL as well.
2. When installing CUDA, WSL-Ubuntu distribution should be choosen; [https://developer.nvidia.com/cuda-downloads?target\_os=Linux&target\_arch=x86\_64&Distribution=WSL-Ubuntu&target\_version=2.0&target\_type=deb\_local](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local)
3. After installed CUDA 12.1, make symbolic link of CUDA precompile file  
(shared object) in /usr/lib/wsl/lib into /usr/lib/x86\_64-linux-gnu  
For example, wsl@username:/usr/lib/x86\_64-linux-gnu$ sudo ln -s /usr/lib/wsl/lib/\* ./

Best

Yuji

---

<div class="post-metadata">

**Author:** ![juneyounglim](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/juneyounglim/32/567_2.png) [@juneyounglim](https://pyfr.discourse.group/u/juneyounglim)\
**Post date:** [26 September 2023 00:00 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/14 "2023-09-26T00:00:15Z")

</div>

Continuing the discussion from [Error: CUDANoDevice on WSL](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/13):

Hi Yuji,

I’m trying to run the example files for the first time, and I encountered the exact same traceback for error as you (finishing with line 33). So I found this thread, and tried the symbolic link thing you kindly noted, but it keeps failing.

I’m now using CUDA 11.8 on WSL, but it would be helpful if I can get some more detailed explanation or link you refered to.

Thank you, June.

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [26 September 2023 05:13 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/15 "2023-09-26T05:13:58Z")

</div>

Hi june,

Could you check the symbolic link in “/usr/lib/x86\_64-linux-gnu” and give me a picture ?  
And aldo Could you give me the picture in " /usr/lib/wsl/lib/"?

---

<div class="post-metadata">

**Author:** ![juneyounglim](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/juneyounglim/32/567_2.png) [@juneyounglim](https://pyfr.discourse.group/u/juneyounglim)\
**Post date:** [26 September 2023 07:34 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/16 "2023-09-26T07:34:51Z")

</div>

Dear Yuji,  
Thank you for your kind reply.

List of symbolic link in “/usr/lib/x86\_64-linux-gnu” is too long to take picture or copy text. Please let me know if there is specific link to check.

Picture in " /usr/lib/wsl/lib/" is:

 ![화면 캡처 2023-09-26 160704](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/3fbe8229e2fde43a04491ec8c635f1f4881f606c.png)

And when I try “wsl@username:/usr/lib/x86\_64-linux-gnu$ sudo ln -s /usr/lib/wsl/lib/\* ./”, I get:

```auto
ln: failed to create symbolic link './libcuda.so': File exists
ln: failed to create symbolic link './libcuda.so.1': File exists
ln: failed to create symbolic link './libcuda.so.1.1': File exists
ln: failed to create symbolic link './libcudadebugger.so.1': File exists
ln: failed to create symbolic link './libd3d12.so': File exists
ln: failed to create symbolic link './libd3d12core.so': File exists
ln: failed to create symbolic link './libdxcore.so': File exists
ln: failed to create symbolic link './libnvcuvid.so': File exists
ln: failed to create symbolic link './libnvcuvid.so.1': File exists
ln: failed to create symbolic link './libnvdxdlkernels.so': File exists
ln: failed to create symbolic link './libnvidia-encode.so': File exists
ln: failed to create symbolic link './libnvidia-encode.so.1': File exists
ln: failed to create symbolic link './libnvidia-ml.so.1': File exists
ln: failed to create symbolic link './libnvidia-opticalflow.so': File exists
ln: failed to create symbolic link './libnvidia-opticalflow.so.1': File exists
ln: failed to create symbolic link './libnvoptix.so.1': File exists
ln: failed to create symbolic link './libnvoptix_loader.so.1': File exists
ln: failed to create symbolic link './libnvwgf2umx.so': File exists
ln: failed to create symbolic link './nvidia-smi': File exists

```

Best regards, June

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [26 September 2023 08:46 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/17 "2023-09-26T08:46:15Z")

</div>

Dear June,

Ok,  
When you made symbolic link, was your directory at “/usr/lib/x86\_64-linux-gnu”?

Could you try these commands?

```auto
$cd /usr/lib/x86_64-linux-gnu
$sudo ln -s /usr/lib/wsl/lib/* ./

```

This is because you need to make symbolic link in /usr/lib/x86\_64-linux-gnu

Yuji

---

<div class="post-metadata">

**Author:** ![juneyounglim](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/juneyounglim/32/567_2.png) [@juneyounglim](https://pyfr.discourse.group/u/juneyounglim)\
**Post date:** [26 September 2023 09:46 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/18 "2023-09-26T09:46:15Z")

</div>

I originally tried at the directory “/usr/lib/x86\_64-linux-gnu” and got the error of above, but now I fixed.

In case someone got error  
`ln: failed to create symbolic link '***' : File exists`  
like me, try  
`ln -sf /usr/lib/wsl/lib/* ./`  
to overwrite symbolic links, instead of  
`ln -s /usr/lib/wsl/lib/* ./`  
which Yuji kindly noted above.

Thank you very much Yuji, for your kind response and notes. It really helped me.

Best regards, June

---

<div class="post-metadata">

**Author:** ![Yujif1Aero](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/yujif1aero/32/448_2.png) [@Yujif1Aero](https://pyfr.discourse.group/u/Yujif1Aero)\
**Post date:** [26 September 2023 12:07 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/19 "2023-09-26T12:07:14Z")

</div>

Good! My pleasure! Were you able to calclate test cases?  
Best,  
Yuji from Tokyo

---

<div class="post-metadata">

**Author:** ![juneyounglim](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/juneyounglim/32/567_2.png) [@juneyounglim](https://pyfr.discourse.group/u/juneyounglim)\
**Post date:** [26 September 2023 13:38 UTC](https://pyfr.discourse.group/t/error-cudanodevice-on-wsl/772/20 "2023-09-26T13:38:40Z")

</div>

Yeah, I calculated examples successfully. Thanks again for your help.

Best regards, June
