Skip to content

Instantly share code, notes, and snippets.

@arendu-zz
Last active October 20, 2017 20:04
Show Gist options
  • Save arendu-zz/d4ec97d90549f13e0027c2eb26d815de to your computer and use it in GitHub Desktop.
Save arendu-zz/d4ec97d90549f13e0027c2eb26d815de to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
__author__ = 'arenduchintala'
import theano
import theano.tensor as T
import numpy as np
a = T.vector('a')
M = T.matrix('M')
func = theano.function(inputs=[a,M], outputs=T.dot(M,a))
a_np = np.float32(np.random.rand(10,))
M_np = np.float32(np.random.rand(10,10))
func(a_np, M_np)
#!/usr/bin/env python
__author__ = 'arenduchintala'
import torch
from torch import cuda
import sys
print cuda.is_available()
#device = int(sys.argv[1]) #get via `free-gpu` in the command line
cuda.set_device(0)
print cuda.current_device()
#make a random tensor and copy it to the gpu
tmp = torch.rand(5,5)
tmp.cuda()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment