Cuda error running examples

Hi everyone. I’m new to PyFR, and trying to run examples after installing the program. But the three examples (2d-euler-vortex, 2d-inc-cylinder, 2d-couette-flow) give me back this error:

Traceback (most recent call last):
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/bin/pyfr", line 8, in <module>
    sys.exit(main())
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/__main__.py", line 118, in main
    args.process(args)
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/__main__.py", line 251, in process_run
    _process_common(
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/__main__.py", line 230, in _process_common
    backend = get_backend(args.backend, cfg)
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/backends/__init__.py", line 12, in get_backend
    return subclass_where(BaseBackend, name=name.lower())(cfg)
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/backends/cuda/base.py", line 20, in __init__
    self.cuda = CUDA()
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/backends/cuda/driver.py", line 445, in __init__
    self.lib.cuInit(0)
  File "/home/jylim0415/.ssh/libxsmm/pyfr-venv/lib/python3.10/site-packages/pyfr/ctypesutil.py", line 35, in _errcheck
    raise self._statuses['*'] from None
pyfr.backends.cuda.driver.CUDAError 

I’m using wsl ubuntu 22.04 and cuda 12.2,
$ nvidia-smi and $ nvcc -V commands are working well.

I’d be grateful if someone could help me.

Kind Regards,
June

Did you add the cuda library path to you LD_LIBRARY_PATH?

See here: CUDA - Post-installation Actions

I already added these lines to .bashrc file and it gives the error.

export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.2/targets/x86_64-linux/lib/stubs:$LD_LIBRARY_PATH                          
export PATH=/usr/local/cuda-12.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH

By the way, nvidia-smi result is this:

Wed Sep 20 10:37:53 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.98.01              Driver Version: 536.99       CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce GTX 1660 ...    On  | 00000000:01:00.0  On |                  N/A |
| 33%   39C    P8              19W / 125W |    426MiB /  6144MiB |      1%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+                                                                                                
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A        23      G   /Xwayland                                 N/A      |
+---------------------------------------------------------------------------------------+

and nvcc -V result is this:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:02:13_PDT_2023
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0

Ok, the fact that it’s failing on the cuInit command makes me think there might be something wrong with your cuda installation.

Can you try compiling and running a simple cuda test program? ie https://github.com/NVIDIA/cuda-samples/blob/03309a2d4275a9186b748e033ee5f90a11492a2f/Samples/0_Introduction/vectorAdd/vectorAdd.cu

Just copy that into a file ending in .cu.

The try

$ nvcc test.cu -o test
$ ./test

It should compile and run succesfully.