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

repr of device is broken #48585

Closed
rgommers opened this issue Nov 30, 2020 · 11 comments
Closed

repr of device is broken #48585

rgommers opened this issue Nov 30, 2020 · 11 comments

Comments

@rgommers
Copy link
Collaborator

rgommers commented Nov 30, 2020

🐛 Bug

The repr of device instances is broken - the index for GPUs is missing, as is a closing bracket. A repr is supposed to be able to be eval-ed (not that that's a good idea typically, but there's no reason for it not being true here).

To Reproduce

In [1]: import torch                                                         

In [2]: t = torch.tensor([1, 2, 3, 4], device='cuda:0')                      

In [3]: t                                                                    
Out[3]: tensor([1, 2, 3, 4], device='cuda:0')

In [4]: t.device                                                             
Out[4]: device(type='cuda', index=

In [5]: repr(t.device)                                                      
Out[5]: "device(type='cuda', index="

In [6]: str(t.device)                                                       
Out[6]: 'cuda:0'

Expected behavior

Repr should be, in the above case, "device(type='cuda', index=0)"

Environment

$ python torch/utils/collect_env.py 
Collecting environment information...
PyTorch version: 1.8.0a0+2fe382e
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Antergos Linux (x86_64)
GCC version: (GCC) 8.4.0
Clang version: 11.0.0
CMake version: version 3.14.0

Python version: 3.7 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 455.38
cuDNN version: Probably one of the following:
/usr/lib/libcudnn.so.8.0.5
/usr/lib/libcudnn_adv_infer.so.8.0.5
/usr/lib/libcudnn_adv_train.so.8.0.5
/usr/lib/libcudnn_cnn_infer.so.8.0.5
/usr/lib/libcudnn_cnn_train.so.8.0.5
/usr/lib/libcudnn_ops_infer.so.8.0.5
/usr/lib/libcudnn_ops_train.so.8.0.5
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.18.1
[pip3] pytorch-sphinx-theme==0.0.24
[pip3] torch==1.8.0a0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2020.0                      166  
[conda] mkl-include               2019.4                      243  
[conda] mkl-service               2.3.0            py37he904b0f_0  
[conda] mkl_fft                   1.1.0            py37h23d657b_0  
[conda] mkl_random                1.1.0            py37hd6b4f25_0  
[conda] numpy                     1.18.1           py37h4f9e942_0  
[conda] numpy-base                1.18.1           py37hde5b4d6_1  
[conda] pytorch-sphinx-theme      0.0.24                    dev_0    <develop>
[conda] torch                     1.8.0a0                   dev_0    <develop>

cc @ezyang @gchanan @zou3519 @bdhirsh

@gchanan
Copy link
Contributor

gchanan commented Nov 30, 2020

confirmed on master.

@gchanan
Copy link
Contributor

gchanan commented Nov 30, 2020

also a regression from 1.7.0.

@gchanan
Copy link
Contributor

gchanan commented Nov 30, 2020

I can't reproduce it in a local build but the nightlies do show the problem.

@sparkingdark
Copy link

Can I work on it and try to give a fix?

@rgommers
Copy link
Collaborator Author

rgommers commented Dec 1, 2020

@sparkingdark please feel free to work on any open issue that's unassigned. In this case it's a high-prio regression, so there's some time pressure, which means someone else may jump in and fix it. If you're new to PyTorch development, I'd usually recommend to pick issues where it's clear what to do and that haven't moved in say a week or two.

@sparkingdark
Copy link

sparkingdark commented Dec 1, 2020

okay I try to do my best and I am new to pytorch development can you tell me how to getting started actually I was looking for good first issue but all of them are taken that's why i am now searching above that. @rgommers

@sparkingdark
Copy link

hey i need some help @rgommers can you tell me how to compile and install the pytorch 1.8.1.8.0a0 is it on the developer branch.
and one thing can I use google colab for testing purpose.

@kshitij12345 kshitij12345 self-assigned this Dec 1, 2020
@kshitij12345
Copy link
Collaborator

@sparkingdark Have a look at https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md#developing-pytorch
That has all the necessary instructions.

@sparkingdark
Copy link

sparkingdark commented Dec 1, 2020 via email

@rgommers
Copy link
Collaborator Author

rgommers commented Dec 2, 2020

Yeah I am new to pytorch development and try to do it,is their any community channels available for pytorch I can join ?

https://discuss.pytorch.org/. A word of advice though: please do your homework first, like searching for the available information on a topic, and then ask a specific question when you do get stuck. That makes it much more likely someone will answer your question.

@sparkingdark
Copy link

sparkingdark commented Dec 2, 2020 via email

shaibagon pushed a commit to shaibagon/pytorch that referenced this issue Dec 3, 2020
Summary:
Fixes pytorch#48585

In the following commit pytorch@4c9eb57, type of `DeviceIndex` was changed from `uint16_t` to `uint8_t`.
`uint8_t` is treated as ascii chars by std::cout and other stream operators. Hence the broken `repr`

Stackoverflow Reference: https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout

Pull Request resolved: pytorch#48655

Reviewed By: bdhirsh

Differential Revision: D25272289

Pulled By: ezyang

fbshipit-source-id: a1549f5f8d417138cf38795e4c373e3a487d3691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants