Reputation: 1699
Whenever I call cudaMemPrefetchAsync()
it returns the error code cudaErrorInvalidDevice
. I am sure that I pass right device id (I have only one CUDA-capable GPU in my laptop under id == 0
).
I believe that code sample posted below is error-free, but at line 52
(call to cudaMemPrefetchAsync()
) I keep getting this error.
(I haven't idea for anything else)
OS: Microsoft windows 8.1 x64 home.
IDE: Visual studio 2015
CUDA toolkit: 8.0.61
NVIDIA GPU: GeForce GTX 960M
NVIDIA GPU driver: ver 381.65 (latest)
Compute Capability: 5.0 (Maxwell)
Unified Memory support: is supported.
Intel integrated gpu: Intel HD graphics 4600
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST AREA:
// -- INCLUDE:
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cuda Libs: ( Device Side ):
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
// Std C++ Libs:
#include <iostream>
#include <iomanip>
///////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST AREA:
// -- NAMESPACE:
/////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
///////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST AREA:
// -- START POINT:
/////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
// Set cuda Device:
if (cudaSetDevice(0) != cudaSuccess)
cout << "ERROR: cudaSetDevice(***)" << endl;
// Array:
unsigned int size = 1000;
double * d_ptr = nullptr;
// Allocate unified memory:
if (cudaMallocManaged(&d_ptr, size * sizeof(double), cudaMemAttachGlobal) != cudaSuccess)
cout << "ERROR: cudaMallocManaged(***)" << endl;
if (cudaDeviceSynchronize() != cudaSuccess)
cout << "ERROR: cudaDeviceSynchronize(***)" << endl;
// Prefetch:
if(cudaMemPrefetchAsync(d_ptr, size * sizeof(double), 0) != cudaSuccess)
cout << "ERROR: cudaMemPrefetchAsync(***)" << endl;
// Exit:
getchar();
}
///////////
Upvotes: 5
Views: 2814