Error installing Pycuda in WSL2

I find an error when trying to install pycuda on WSL2 (Windows 10) following the command:

pip install pycuda

the error log is huge but it closes with:

ERROR: Failed building wheel for pycuda
Failed to build pycuda
ERROR: Could not build wheels for pycuda, which is required to install pyproject.toml-based projects

I also attached the full log to this post

I already tested the nvidia-smi command to verify if there is the right configuration of the GPUs and there is not problem.

+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.23.07              Driver Version: 546.12       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| 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 RTX A4500               On  | 00000000:17:00.0 Off |                  Off |
| 30%   28C    P8               9W / 200W |      0MiB / 20470MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   1  NVIDIA RTX A4500               On  | 00000000:73:00.0  On |                  Off |
| 30%   31C    P8              12W / 200W |   1509MiB / 20470MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

I also called the GPUs on tensorflow following tf.config.get_visible_devices('GPU') and it finds my GPUs.

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'), PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU')]

I’m running out of ideas of what could be happening. Could you help me to understand what I’m missing? Thanks!
pycuda.log (2.5 MB)

hello
yesterday i’d a similar error but in ubuntu 22.04
my solution was :

  1. update/reinstall cuda
  2. update/reinstall nvidia-smi driver
  3. pip3 install pycuda

i hope it’ll work for you

kind regards and have a nice day