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

How can I access data in cuda kernel like in pytorch? #79

Open
Arsmart123 opened this issue Jun 9, 2022 · 0 comments
Open

How can I access data in cuda kernel like in pytorch? #79

Arsmart123 opened this issue Jun 9, 2022 · 0 comments

Comments

@Arsmart123
Copy link

Arsmart123 commented Jun 9, 2022

  • OS: win10
  • PyTorch version: 1.10
  • How you installed PyTorch (conda, pip, source): pip
  • Python version: 3.9
  • CUDA/cuDNN version: 11.3
  • GPU models and configuration: 1650 geforce PC
  • GCC version (if compiling from source): not sure/.....

I have a tensor a in pytorch, a. And then I transpose it to have a1. But it will not really transpose in memory, but just change the way we read it. And then we pass this pointer to the cuda kernel like is written in the tutorial. Then we access it within the kernel. It is not transposed!!!!! But we enter the pytorch interface and print out the transposed a1, it is correct!

How can we access the tensor within the kernel? We do not know whether it is
transposed or not!!!!

Thank you!!!
test.zip
I have attached a file here. You can reproduce it by unzip it.
Then open a python env with pytorch. Also have GPU
Then enter: python pytorch/setup.py install
You will install the "add3" library.
Then run the "delete.py" file within it. You will see how the bug appears like I discribe above!!

Another way to solve it is to understand how nn.linear solve it. How they can access data correctly? I think this is the implementation for nn.linear inside:
https://github.com/pytorch/pytorch/blob/4cb534f92ef6f5b2ec99109b0329f93a859ae831/torch/csrc/api/src/nn/modules/linear.cpp
But again it links to "torch::nn::linear" And I really can not find the cpp code for it.....

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

1 participant