Skip to content

Commit

Permalink
Fix CUDA test hang: (microsoft#6138)
Browse files Browse the repository at this point in the history
- Make condition check in `CUDAAllocatorTest` to ensure CUDA device is present.
  • Loading branch information
toothache authored Dec 16, 2020
1 parent b648bf6 commit 0978d2b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions onnxruntime/test/framework/cuda/allocator_cuda_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace onnxruntime {
namespace test {
TEST(AllocatorTest, CUDAAllocatorTest) {
OrtDevice::DeviceId cuda_device_id = 0;

// ensure CUDA device is avaliable.
CUDA_CALL_THROW(cudaSetDevice(cuda_device_id));

AllocatorCreationInfo default_memory_info(
{[](OrtDevice::DeviceId id) { return onnxruntime::make_unique<CUDAAllocator>(id, CUDA); }, cuda_device_id});

Expand Down

0 comments on commit 0978d2b

Please sign in to comment.