Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot re-initialize CUDA in forked subproess #129

Open
chumingqian opened this issue Apr 2, 2023 · 1 comment
Open

cannot re-initialize CUDA in forked subproess #129

chumingqian opened this issue Apr 2, 2023 · 1 comment

Comments

@chumingqian
Copy link

chumingqian commented Apr 2, 2023

Is any friend meet this situation,

i already solve this problem :
by using

import torch.multiprocessing as mp

def get_mean_and_std_4channel(dataset):
    '''Compute the mean and std value of dataset.'''
    mp.set_start_method('spawn') # set multiprocessing context to 'spawn'
    dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, shuffle=True, num_workers=2, multiprocessing_context='spawn')
    mean = torch.zeros(4)

However , the cuda also dumped because out of memory, for the 380*400 resolution, batch size =2, channel=3, nfft =2048, but i set trainable Mel and stft both are False.

It takes 23 G cuda memory,

so, is there any method reduce the cuda memory cost

@KinWaiCheuk
Copy link
Owner

I am not sure how is your dataset written.
Have you tried putting the nnAudio after the dataloader instead of inside it? What is the memory required if you do it like this?

i.e. you load a batch of waveforms first, then use nnAudio to convert that batch of waveforms into spectrograms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants