KEMBAR78
Initialize cuda before setting cuda tensor types as default by zou3519 · Pull Request #4788 · pytorch/pytorch · GitHub
Skip to content

Conversation

@zou3519
Copy link
Contributor

@zou3519 zou3519 commented Jan 22, 2018

Fixes #4784.

If CUDA hasn't been initialized yet, the following fails with a weird error:

import torch
torch.set_default_tensor_type("torch.cuda.FloatTensor")

This fixes that.

Test Plan

I'm not sure how to write unit tests for this because CUDA is probably initialized by the time a unit test is called.

Ran the above script on a CPU only installation and a CUDA enabled installation.

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

Successfully merging this pull request may close these issues.

unsupported Python type error from set_default_tensor_type()

3 participants