For this reason the function fails in WSL where the returned process name is in ANSI. ANSI encoding is not well-supported in Linux though.
A proposed solution would be to have a special case for windows (it already exists in other parts of the library) or set errors="ignore" for this specific function call (as it appears to be the only encoded in ANSI from the documentation)
Minimal Example
from pynvml.smi import nvidia_smi as smi
import torch
torch.randn(1000).to("cuda")
_instance = smi.getInstance()
# fails here
device = _instance.DeviceQuery()
device["gpu"][0]["processes"]
nvmlSystemGetProcessName
https://docs.nvidia.com/deploy/nvml-api/group__nvmlSystemQueries.html#group__nvmlSystemQueries_1gf37b04cea12ef2fcf6a463fed1b983b2Based on the documentation returns the a string encoded in ANSI.
However it is automatically decoded in "utf-8"
https://github.com/gpuopenanalytics/pynvml/blob/43a7803c42358a87e765bb66373f3ae536d589a3/pynvml/nvml.py#L1744
For this reason the function fails in WSL where the returned process name is in ANSI. ANSI encoding is not well-supported in Linux though.
A proposed solution would be to have a special case for windows (it already exists in other parts of the library) or set
errors="ignore"
for this specific function call (as it appears to be the only encoded in ANSI from the documentation)Minimal Example