error:
only integer tensors of a single element can be converted to an index
userEmbeddings = self.userEmbeds[userIndex]
movieEmbeddings = self.movieEmbeds[movieIndex]
To -->
userEmbeddings = self.userEmbeds(userIndex)
movieEmbeddings = self.movieEmbeds(movieIndex)
can't covert CUDA tensor to numpy. use Tensor.cpu() to copy the tensor to host memory first.
Change
index = output.data.numpy().argmax()
to
index = output.cpu().data.numpy().argmax()
指定GPU运行python程序
一、命令行运行python程序时
1、首先查看哪些GPU空闲,nvidia-smi显示当前GPU使用情况。
1 |
|
2、然后指定空闲的GPU运行python程序。
1 |
|
二、在python程序中指定GPU
1 2 |
|
周期性输出GPU使用情况
每 10s 显示一次GPU使用情况:
1 |
|
convert list to tensor: torch.Tensor(a)