0

Is it required to dispose Worker.Default or CUBLAS.Default?

My CUDA code runs correctly but I get the following exception when the program exits:

Got CUDA error CUDA_ERROR_INVALID_VALUE
   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Alea.CUDA.CUDAInterop.cuSafeCall(cudaError_enum result)
   at <StartupCode$Alea-CUDA>.$Engine.f@1-46[T](WorkerContext this, FSharpFunc`2
 f, Unit _arg6)
   at Alea.CUDA.WorkerContext.eval[T](FSharpFunc`2 f)
   at Alea.CUDA.Program.Dispose(Boolean disposing)
Got CUDA error CUDA_ERROR_INVALID_VALUE
   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Alea.CUDA.CUDAInterop.cuSafeCall(cudaError_enum result)
   at <StartupCode$Alea-CUDA>.$Engine.f@1-46[T](WorkerContext this, FSharpFunc`2
 f, Unit _arg6)
   at Alea.CUDA.WorkerContext.eval[T](FSharpFunc`2 f)
   at Alea.CUDA.Program.Dispose(Boolean disposing)

Can I use Worker.Default and CUBLAS.Default in multiple classes or should I create one and pass this to anyone who needs a worker?

Thanks Johan

talonmies
  • 70,661
  • 34
  • 192
  • 269
Johan
  • 660
  • 1
  • 6
  • 13

1 Answers1

1

Although worker can be disposed, but it is not suggested that you dispose it. Worker represents a CUDA context, and should be long lived. The default worker and default cublas object are built on your default GPU device.

Xiang Zhang
  • 2,831
  • 20
  • 40