Skip to content

std::bad_alloc #21

@cindity

Description

@cindity

Hi @lematt1991 ,
Thank you for your excellent work on this project.

I’ve received approval on Hugging Face and successfully set up the SAM Audio repository on my local machine with GPU support (23 GB VRAM). However, when running the following code, I encounter a std::bad_alloc error:

from sam_audio import SAMAudio, SAMAudioProcessor
import torchaudio

model = SAMAudio.from_pretrained("facebook/sam-audio-large")
processor = SAMAudioProcessor.from_pretrained("facebook/sam-audio-large")
model = model.eval().cuda()

# audio file path or torch tensor
file = "/code/fwd-local-scripts/pitchshift/new_voices/raw_mp3/my_voice.mp3"
description = ["A man speaking"]

batch = processor(
    audios=[file],
    descriptions=[description]).to("cuda")

result = model.separate(batch)

# Save separated audio
sample_rate = processor.audio_sampling_rate
torchaudio.save("target.wav", result.target.cpu(),
                sample_rate)      # The isolated sound
torchaudio.save("residual.wav", result.residual.cpu(),
                sample_rate)  # Everything else
root@9122383de6d5:/code/sam-audio# df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm              16G     0   16G   0% /dev/shm

root@9122383de6d5:/code/sam-audio# cat /sys/fs/cgroup/memory.max 2>/dev/null || cat /sys/fs/cgroup/memory/memory.limit_in_bytes
34359738368

root@9122383de6d5:/code/sam-audio# python tools/text_prompting.py 
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

Can you share how I can debug this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions