Self defined Operator
I implement a self defined loss operator. Some kernel functions can't be implemented using mshadow, so I use self defined kernel functions in .cu file. The problem is the result is not deterministic. However when I change the MXNET_ENGINE_TYPE to NaiveEngine, the results of different times are the same. I guess it is some synchoronize problem of my kernel. So I add cudaThreadSynchronize before the kernel and cudaStreamSynchronize after the kenrel, as the following presudo code shows . But the result is still not deterministic.
Stream
non deterministic as in random error or slight difference between runs?
@piiswrong slight difference between runs. Using NaiveEngine won't have this problem, so it may be the problem of synchronization
Are you sure the diff is from this layer? Is it's input deterministic?
@piiswrong Yes, I replaced the self define loss layer with softmaxoutput, the results between runs are the same. What't more, if the input is non deterministic, I won't get the same value with NaiveEngine
can you verify that the input to your loss layer is the same by binding it as a additional output? If it's indeed the same. Try a simpler kernel to see which operation in your kernel is causing this.
The input to the loss layer is definitely the same. I extract the self-defined kernels codes, and do a unit-test, they have no problem. I find two ways to eliminate this no deterministic phenomenon. The First is as I mentioned above, using the naive engine. Another way is setting the MXNET_GPU_WORKER_NTHREADS to 1. I still can't figure out why it happens. Is there any thing should be noticed when writing a self defined kernel?
This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!