MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / CudaCurrentDeviceGuard

Method CudaCurrentDeviceGuard

oneflow/core/device/cuda_util.cpp:173–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173CudaCurrentDeviceGuard::CudaCurrentDeviceGuard(int32_t dev_id) {
174 CHECK(!pthread_fork::IsForkedSubProcess()) << pthread_fork::kOfCudaNotSupportInForkedSubProcess;
175 OF_CUDA_CHECK(cudaGetDevice(&saved_dev_id_));
176 OF_CUDA_CHECK(cudaSetDevice(dev_id));
177}
178
179CudaCurrentDeviceGuard::CudaCurrentDeviceGuard() { OF_CUDA_CHECK(cudaGetDevice(&saved_dev_id_)); }
180

Callers

nothing calls this directly

Calls 1

IsForkedSubProcessFunction · 0.85

Tested by

no test coverage detected