question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example fails on GPU

See original GitHub issue

When running the example from the README:

from soft_dtw_cuda import SoftDTW
import torch
# Create the sequences
batch_size, len_x, len_y, dims = 8, 15, 12, 5
x = torch.rand((batch_size, len_x, dims), requires_grad=True)
y = torch.rand((batch_size, len_y, dims))
# Create the "criterion" object
sdtw = SoftDTW(use_cuda=True, gamma=0.1)
# Compute the loss value
loss = sdtw(x, y)  # Just like any torch.nn.xyzLoss()
# Aggregate and call backward()
loss.mean().backward()

I get a TypeError:

Traceback (most recent call last):
  File "test_dtw.py", line 10, in <module>
    loss = sdtw(x, y)  # Just like any torch.nn.xyzLoss()
  File "/home/dockeruser/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/dockeruser/soft_dtw_cuda.py", line 352, in forward
    return func_dtw(D_xy, self.gamma, self.bandwidth)
  File "/home/dockeruser/soft_dtw_cuda.py", line 140, in forward
    compute_softdtw_cuda[B, threads_per_block](cuda.as_cuda_array(D.detach()),
  File "/home/dockeruser/env/lib/python3.7/site-packages/numba/cuda/api.py", line 74, in as_cuda_array
    raise TypeError("*obj* doesn't implement the cuda array interface.")
TypeError: *obj* doesn't implement the cuda array interface.

Potentially relevant packages from my env: Cython 0.29.24 numba 0.54.0 torch 1.6.0

Any suggestions?

BTW. Thanks a lot for porting to cuda!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Yutaro-Sanadacommented, Nov 19, 2021

I also encountered. However, after inserting two lines before sdtw = SoftDTW(use_cuda=True, gamma=0.1), I can run this example.

x = x.cuda()
y = y.cuda()
0reactions
Maghoumicommented, Nov 19, 2021

#17 is now merged. Closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Graphics Card Error and Video Issues?
Part 2. How to Fix Graphics Card Errors · 1. Cool Down the Temperature · 2. Update The Drivers · 3. Is Your...
Read more >
What are the most common reasons for GPU cards to fail?
Poor education on what it takes to make a successful marriage. · Poor selection of spouses, where people ignore major incompatibilties, have unrealistic ......
Read more >
examples\imagenet\models_test.py fails on GPU (8 x Titan-m)
Problem you have encountered: Running flax\examples\imagenet\models_test.py hits runtime error. What you expected to happen: Test to exit ...
Read more >
5 Signs Your Graphics Card Has Problems and May Be Dying
Video cards can fail for so many different reasons. Not properly installing the component in the computer can lead to video card failure,...
Read more >
Flux Pendulum DDPG example fails on GPU - Julia Discourse
It seems to work on my CPU but on the GPU get a weird error which seems to be related to CUDA.jl not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found