How to configure shared memory size?

I want to put the elements in a list to shared memory. The code ( is as follows.

import torch
if __name__=='__main__':
    mylist = []
    list_len = 10000
    for i in range(list_len):
        element = torch.randn(10)

    for element in mylist:

The problem is that, when I run “python” from command line, it outputs the following error

Traceback (most recent call last):
  File "", line 9, in <module>
  File "/home/rozyang/anaconda3/lib/python3.6/site-packages/torch/", line 217, in share_memory_
  File "/home/rozyang/anaconda3/lib/python3.6/site-packages/torch/", line 104, in share_memory_
RuntimeError: unable to open shared memory object </torch_1543_4219316339> in read-write mode at /opt/conda/conda-bld/pytorch_1524590031827/work/aten/src/TH/THAllocator.c:342

However, no error appears when I run the same code in PyCharm. I have checked that PyCharm is using the same python interpreter and same pytorch.

If I change “list_len=10000” to “list_len=100”, the command line “python” also works.

So I am wondering where there is somewhere I can set the shared memory size (i.e. the number of shared variables). Many thanks to any hints to solve this!

P.S. I am using anaconda python 3.6 and pytorch 0.4.0

1 Like

Meet the same problem here. Have you found any solution?