You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/09/22 19:23:46 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #19209: [BUGFIX]Fix cuDNN dropout reproducibility

szha commented on a change in pull request #19209:
URL: https://github.com/apache/incubator-mxnet/pull/19209#discussion_r492979125



##########
File path: src/resource.cc
##########
@@ -428,37 +486,28 @@ void* Resource::get_host_space_internal(size_t size) const {
 void Resource::get_cudnn_dropout_desc(
     cudnnDropoutDescriptor_t *dropout_desc,
     mshadow::Stream<gpu> *stream,
-    const float dropout, uint64_t seed,
+    const float dropout,
     const std::string &name) const {
 
   CHECK_EQ(req.type, ResourceRequest::kCuDNNDropoutDesc);
   auto state_space = static_cast<resource::SpaceAllocator*>(ptr_);
   CHECK_EQ(state_space->ctx.dev_id, stream->dev_id)
-    << "The device id of cuDNN dropout state space doesn't match that from stream.";
-  CUDNN_CALL(cudnnCreateDropoutDescriptor(dropout_desc));
+    << "The device id of cudnn dropout state space doesn't match that from stream.";
   if (dropout <= 0) {
     CUDNN_CALL(cudnnSetDropoutDescriptor(*dropout_desc, stream->dnn_handle_,
                                          dropout,
                                          nullptr,
                                          0, seed));
-  } else if (!state_space->handle.size) {
-    // not initialized yet.
-    size_t dropout_state_size;
-    CUDNN_CALL(cudnnDropoutGetStatesSize(stream->dnn_handle_, &dropout_state_size));
-    // reserve GPU space
-    Storage::Get()->DirectFree(Storage::Get()->Alloc(dropout_state_size, state_space->ctx));
-    CUDNN_CALL(cudnnSetDropoutDescriptor(*dropout_desc, stream->dnn_handle_,
-                                         dropout,
-                                         state_space->GetSpace(dropout_state_size, name),
-                                         dropout_state_size, seed));
   } else {
+    CHECK(state_space->handle.size > 0)
+      << "CUDNN dropout descriptor was not initialized yet!";
     // cudnnRestoreDropoutDescriptor() introduced with cuDNN v7
     STATIC_ASSERT_CUDNN_VERSION_GE(7000);
     CUDNN_CALL(cudnnRestoreDropoutDescriptor(*dropout_desc, stream->dnn_handle_,
                                              dropout,
                                              state_space->handle.dptr,
                                              state_space->handle.size,
-                                             seed));
+                                             0));

Review comment:
       does the seed not matter?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org