make_grid broken with mps device Tensors, whole grid is the 'first' image
See original GitHub issueš Describe the bug
When calling make_grid on Tensor and List of Tensors where the device in āmpsā it returns a grid where all the Tensors are the same.
Simple example create a venv and activate cd into the venv directory install the nightlies pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
unzip the attached zip file, it contains a python script and two images. validate the python script and run it.
from PIL import Image
from torchvision.utils import make_grid
import torchvision.transforms as transforms
import torch
img1 = Image.open('00035.png')
img2 = Image.open('00036.png')
transform = transforms.Compose([
transforms.PILToTensor()
])
t_img1 = transform(img1).to(torch.device("mps"), dtype=torch.float32) / 256.0
t_img2 = transform(img2).to(torch.device("mps"), dtype=torch.float32) / 256.0
grid = make_grid([t_img1, t_img2], nrow=1)
gridImage = transforms.ToPILImage()(grid.cpu());
gridImage.save('mps_grid.png')
t_img1 = transform(img1).to(torch.device("cpu"), dtype=torch.float32) / 256.0
t_img2 = transform(img2).to(torch.device("cpu"), dtype=torch.float32) / 256.0
grid = make_grid([t_img1, t_img2], nrow=1)
gridImage = transforms.ToPILImage()(grid.cpu());
gridImage.save('cpu_grid.png')
It generate two images, youāll see the cpu_grid image are the two images vertically stacked, the mps_grid image has the same image vertically stacked twice.
Versions
PyTorch version: 1.13.0.dev20220901 Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A
OS: macOS 12.5.1 (arm64) GCC version: Could not collect Clang version: 13.1.6 (clang-1316.0.21.2.5) CMake version: version 3.22.4 Libc version: N/A
Python version: 3.10.4 (main, May 10 2022, 03:52:14) [Clang 13.0.0 (clang-1300.0.29.30)] (64-bit runtime) Python platform: macOS-12.5.1-arm64-arm-64bit Is CUDA available: False CUDA runtime version: No CUDA GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True
Versions of relevant libraries: [pip3] numpy==1.23.2 [pip3] torch==1.13.0.dev20220901 [pip3] torchaudio==0.13.0.dev20220901 [pip3] torchvision==0.14.0.dev20220901 [conda] Could not collect
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (3 by maintainers)
Iāve edited the code, but it will be a while before I can test the edit is right, looks like a reference to the zip file split a line in half.
Thanks for raising it at PyTorch Core. I believe the issue is there so Iāll close this issue to avoid duplicates. Iāll keep an eye on the other issue but if it turns out the problem is on TorchVisionās end, feel free to reopen.