DavidDiazGuerra / gpuRIR

Python library for Room Impulse Response (RIR) simulation with GPU acceleration
GNU Affero General Public License v3.0
488 stars 94 forks source link

GPUassert: invalid configuration argument #46

Open JCCC0328 opened 1 year ago

JCCC0328 commented 1 year ago

Hi,I encountered the following error when running the code. How can I resolve it? GPUassert: invalid configuration argument /raid/chenjincheng/package/gpuRIR-master/src/gpuRIR_cuda.cu 672

DavidDiazGuerra commented 1 year ago

Hi, that's probably related to the arguments you used to call the function, but it's hard to know only from that error log. Could you share the code to replicate the error?

JCCC0328 commented 1 year ago

import numpy as np import soundfile as sf import torchvision from gpuRIR import simulateRIR import os os.environ["CUDA_VISIBLE_DEVICES"] = '4'

audio, sr = sf.read("recapnet-vctk_p225_013_50cm.wav")

room_size = [5, 4, 3]
reflection_coeffs = [0.8, 0.7, 0.6, 0.5, 0.4, 0.3]
source_positions = np.array([[2, 2, 1]]) receiver_positions = np.array([[3, 3, 2]])
image_sources = [3, 3, 3]
rir_length = len(audio) / sr
sampling_rate = sr

rir = simulateRIR(room_size, reflection_coeffs, source_positions, receiver_positions, image_sources, rir_length, sampling_rate)

Here is my code above, and below is the error message.

GPUassert: invalid configuration argument /raid/chenjincheng/package/gpuRIR-master/src/gpuRIR_cuda.cu 672

DavidDiazGuerra commented 1 year ago

The issue is probably that you're asking for a too-long RIR. I don't know how long is your file recapnet-vctk_p225_013_50cm.wav, but I can guess it's at least several seconds long. The length of the RIR is not supposed to be the length of the signal but just the length of the filter. It will be longer or shorter depending on the reverberation level that you're trying to simulate, I usually use the $T_{60}$ (i.e. the time that the reverberation needs decrease 60dB) or even less for this.

Btw, rir_length is just controlling the length of the filter in memory, but it doesn't mean that all those samples are going to be filled with the RIR. If you use too low values of image_sources and a large value of rir_length, you're just going to get the beginning of the RIR in the first samples and then a lot of 0s.

I don't know your application so I don't know if this is possible, but in general, I first choose the $T_{60}$ and the room size, and then I compute values for reflection_coeffs, image_sources, and rir_length which makes sense for them. The library contains some functions to do this using the Sabine equation, you can see how they work in this example: https://github.com/DavidDiazGuerra/gpuRIR/blob/master/examples/example.py

JCCC0328 commented 1 year ago

Thanks a lot ,I'll give it a try