Cuda error in torchaudio spectrogram

giampierosalvi: <p>I am running the same code on two machines running Ubuntu 20.04. In one machine the code runs fine, in the other I get the error reported below. The only difference I can see are the graphic cards (NVIDIA Titan Xp in the machine that works and NVIDIA GeForce RTX 3090 in the one that doesn’t). The version of torch and torchaudio are 1.5.0 and 0.5.0 (these are required for the experiment to be reproducible). The machine that works runs python 3.7.9, the one that doesn’t runs python 3.8.10. Both machines have cuda V10.1.243.</p>
<p>Let me know if there is other information that I missed and that is relevant to this question.</p>
<p>Do you have any suggestion on what to look for to solve this problem?<br>
Thank you!<br>
Giampiero</p>
<p>Using device ‘cuda:0’<br>
Creating Datasets<br>
Calculating mean and std from dataset<br>
Traceback (most recent call last):<br>
File “main.py”, line 665, in <br>
main(args)<br>
File “main.py”, line 621, in main<br>
task_and_more, dataloaders, model_and_more = prepare_for_task(args)<br>
File “main.py”, line 555, in prepare_for_task<br>
datasets = create_datasets(args, paths[‘data_path’], flags[‘load_dataset_extra_stats’])<br>
File “main.py”, line 252, in create_datasets<br>
datasets = set_transforms_on_datasets(args, datasets, transforms_device)<br>
File “main.py”, line 303, in set_transforms_on_datasets<br>
stats = get_dataset_stats_and_write(datasets[‘train’], args[‘device’],<br>
File “…/preprocessing.py”, line 79, in get_dataset_stats_and_write<br>
mean, std, min_val, max_val = calc_dataset_stats(dataloader, device=device)<br>
File “…/processing.py”, line 72, in calc_dataset_stats<br>
input_channel = dataloader.dataset[0][‘image’].shape[0]<br>
File “…/CLEAR_dataset.py”, line 433, in <strong>getitem</strong><br>
game_with_image = self.transforms(game_with_image)<br>
File “…/venv/lib/python3.8/site-packages/torchvision/transforms/transforms.py”, line 61, in <strong>call</strong><br>
img = t(img)<br>
File “…/data_interfaces/transforms.py”, line 36, in <strong>call</strong><br>
specgram = self.spectrogram_transform(sample[‘image’])[0, :, :]<br>
File “…/venv/lib/python3.8/site-packages/torch/nn/modules/module.py”, line 550, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “…/venv/lib/python3.8/site-packages/torchaudio/transforms.py”, line 81, in forward<br>
return F.spectrogram(waveform, self.pad, self.window, self.n_fft, self.hop_length,<br>
File “…/venv/lib/python3.8/site-packages/torchaudio/functional.py”, line 276, in spectrogram<br>
spec_f /= window.pow(2.).sum().sqrt()<br>
RuntimeError: CUDA error: invalid device function</p>

ptrblck: <p>Your Ampere GPU (RTX 3090) needs CUDA&gt;=11.0 and I don’t know which exact PyTorch binary (or source build) you’ve installed.<br>
In any case, the CUDA11 support came on PyTorch ~1.7 so your 1.5.0 installation will most likely be using CUDA10, which is causing the error.</p>
<aside class="quote no-group" data-username="giampierosalvi" data-post="1" data-topic="134381">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/giampierosalvi/48/43052_2.png" class="avatar"> giampierosalvi:</div>
<blockquote>
<p>Both machines have cuda V10.1.243.</p>
</blockquote>
</aside>
<p>The pip wheels and conda binaries ship with their own CUDA runtime and your local CUDA toolkit is used for a source build or to build custom CUDA extensions.</p>

giampierosalvi: <p>Thank you for the quick reply. You are right, I got it to work with<br>
pip uninstall torch torchvision torchaudio<br>
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f <a href="https://download.pytorch.org/whl/torch_stable.html" rel="noopener nofollow ugc">https://download.pytorch.org/whl/torch_stable.html</a></p>
<p>Best</p>