Last active
January 21, 2020 00:10
-
-
Save piEsposito/fbed1b642f76fb628d8f3f7b57d1214c to your computer and use it in GitHub Desktop.
Setting up the device for PyTorch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#On the tutorial, we use rather use Intel MKL because of its performance and availability to be used on lower end PCs | |
#Anyway, if you want it, you can try it on CUDA by uncommenting it. | |
#use_cuda = torch.cuda.is_available() | |
use_cuda = False | |
device = torch.device('cuda' if use_cuda else 'cpu') | |
FloatTensor = torch.cuda.FloatTensor if use_cuda else torch.FloatTensor | |
LongTensor = torch.cuda.LongTensor if use_cuda else torch.LongTensor | |
DoubleTensor = torch.cuda.DoubleTensor if use_cuda else torch.DoubleTensor | |
torch.manual_seed(0) | |
np.random.seed(0) | |
random.seed(0) | |
if use_cuda: | |
torch.cuda.manual_seed(0) | |
torch.cuda.manual_seed_all(0) | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment