potential race condition: require 'image'

已查看 16 次
跳至第一个未读帖子

Alexander Weiss

未读,
2016年6月23日 14:32:342016/6/23
收件人 torch7
I'm using the threads package to create a thread pool.  When I initiate the thread pool, I call require 'image' for each thread.  Sometimes this causes the program to freeze up.  If the number of threads is small, the freezing is less likely.  If it is large, the freezing happens almost every time.  Below is a minimal example with 6 threads.  For me, this freezes up about half the time:

local threads = require 'threads'
threads.serialization('threads.sharedserialize')
local num_threads = 6
local pool = threads.Threads(
num_threads,
function(thread_ID)
print(thread_ID .. ' before')
require 'image'
print(thread_ID .. ' after')
end
)
print 'DONE'


If the number of threads is increased to 10, it freezes up essentially every time.  I don't know if this problem is specific to the image package.  I have torch, threads and image packages up-to-date.  I am using Ubuntu16.04.

Alexander Weiss

未读,
2016年6月23日 15:40:412016/6/23
收件人 torch7
This appears to be system dependent.  I tried the same code on an Ubuntu 14.04 system, and it never freezes.  (Both of my systems are on AWS.)

soumith

未读,
2016年6月23日 23:28:182016/6/23
收件人 torch7 on behalf of Alexander Weiss
Hmmm, I'm not able to reproduce it either. A hack for this weirdness can be a mutex around the "require" calls (or even a small randomized sleep). I expect that something about the underlying dlopen that is called when "require 'image'" is being weird on your system.

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at https://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

回复全部
回复作者
转发
0 个新帖子