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

Crashes on 1-GPU with log access error #2

Open
gwern opened this issue Oct 21, 2019 · 1 comment
Open

Crashes on 1-GPU with log access error #2

gwern opened this issue Oct 21, 2019 · 1 comment

Comments

@gwern
Copy link

gwern commented Oct 21, 2019

When I run IntroVAE on 1 GPU (to test how it works on my anime faces), I get indexing/scalar errors from PyTorch (TypeError: only integer scalar arrays can be converted to a scalar index), which appear to be due to the [0] accessors (I assume because it assumes that there are multiple GPUs and multiple metrics, so it tries to access the first one, but it's not a list/array but a value and that makes no sense). To make IntroVAE run, I need to patch it to remove them from the logging statements:

-        info += 'Rec: {:.4f}, '.format(loss_rec.data[0])
-        info += 'Kl_E: {:.4f}, {:.4f}, {:.4f}, '.format(lossE_real_kl.data[0],
-                                lossE_rec_kl.data[0], lossE_fake_kl.data[0])
-        info += 'Kl_G: {:.4f}, {:.4f}, '.format(lossG_rec_kl.data[0], lossG_fake_kl.data[0])
-
+
+        info += 'Rec: {:.4f}, '.format(loss_rec.data)
+        info += 'Kl_E: {:.4f}, {:.4f}, {:.4f}, '.format(lossE_real_kl.data,
+                                lossE_rec_kl.data, lossE_fake_kl.data)
+        info += 'Kl_G: {:.4f}, {:.4f}, '.format(lossG_rec_kl.data, lossG_fake_kl.data)

Might be worth fixing somehow, or at least documenting.

@EtienneDesticourt
Copy link

This is not related to the number of GPUs, .data[0] was used to access the underlying python float from a size 1 tensor in previous versions of pytorch. The preferred way is now .item().

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

2 participants