AlexHex7 / Non-local_pytorch

Implementation of Non-local Block.
Apache License 2.0
1.57k stars 277 forks source link

Cuda Out of memory problem #7

Closed guangmingboy closed 6 years ago

guangmingboy commented 6 years ago

if torch.cuda.is_available(): net.cuda() should be if torch.cuda.is_available(): net.cuda(cfg.cuda_num) ?

When I run demo_MNIST.py, It shows RuntimeError: cuda runtime error (2) : out of memory at THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1524577177097/work/aten/src/THC/generic/THCStorage.cu line=58 error=2 : out of memory

AlexHex7 commented 6 years ago

net.cuda() will use GPU 0 default.

  1. If you want to run the the code in GPU 0, you can run ''python demo_MNIST.py' and both net.cuda() or net.cuda(0) works.

  2. If you want to run the the code in GPU 1, you can run ''python demo_MNIST.py' with net.cuda(1). or you can run 'CUDA_VISIBLE_DEVICES=1 python demo_MNIST.py' with net.cuda() or net.cuda(0).