Torch.cuda.is_available() is False on ZeroGPU Space

/usr/local/lib/python3.10/site-packages/torch/cuda/__init__.py:734: UserWarning: Can't initialize NVML
  warnings.warn("Can't initialize NVML")
Using device: cpu
Loading Nari model...

config.json:   0%|          | 0.00/1.08k [00:00<?, ?B/s]
config.json: 100%|██████████| 1.08k/1.08k [00:00<00:00, 7.24MB/s]

dia-v0_1.pth:   0%|          | 0.00/6.44G [00:00<?, ?B/s]
dia-v0_1.pth:   1%|▏         | 94.4M/6.44G [00:01<01:08, 92.9MB/s]
dia-v0_1.pth:  23%|██▎       | 1.46G/6.44G [00:02<00:06, 830MB/s] 
dia-v0_1.pth:  50%|████▉     | 3.22G/6.44G [00:03<00:02, 1.25GB/s]
dia-v0_1.pth:  75%|███████▌  | 4.85G/6.44G [00:04<00:01, 1.40GB/s]
dia-v0_1.pth: 100%|█████████▉| 6.44G/6.44G [00:05<00:00, 1.27GB/s]
Error loading Nari model: Error loading checkpoint from /home/user/.cache/huggingface/hub/models--nari-labs--Dia-1.6B/snapshots/ea1fb6655d1de2f270f1b0ee6743bba7465f407a/dia-v0_1.pth
Traceback (most recent call last):
  File "/home/user/app/dia/model.py", line 91, in from_local
    dia.model.load_state_dict(torch.load(checkpoint_path, map_location=device))
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1462, in load
    return _load(
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1964, in _load
    result = unpickler.load()
  File "/usr/local/lib/python3.10/site-packages/torch/_weights_only_unpickler.py", line 512, in load
    self.append(self.persistent_load(pid))
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1928, in persistent_load
    typed_storage = load_tensor(
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1900, in load_tensor
    wrap_storage=restore_location(storage, location),
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1806, in restore_location
    return default_restore_location(storage, str(map_location))
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 693, in default_restore_location
    result = fn(storage, location)
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 631, in _deserialize
    device = _validate_device(location, backend_name)
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 600, in _validate_device
    raise RuntimeError(
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Trying to get my Space up with a ZeroGPU.
But failing due to torch.cuda.is_available() being False?!

Can someone please help me…

1 Like

descript-audio-codec>=1.0.0
gradio>=5.25.2
huggingface-hub>=0.30.2
numpy>=2.2.4
pydantic>=2.11.3
soundfile>=0.13.1
torchaudio>=2.0.0
torch>=2.0.0

is requirements.txt

here’s the link to space: Dia 1.6B - a Hugging Face Space by nari-labs

1 Like

Fixed it by using @spaces.
Sorry for the noob-issue.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.