我正在运行以下代码。但是,我得到的输出为 Got error with code 38 test = 0 deviceCount= 0 Got error with code 38 test2 = 0 我在 Ubuntu 上有一块 NVIDIA GTX 690 显卡。这是否意味着驱动程序未激活?
#include <iostream>
using namespace std;
__device__ __constant__ float* data;
template<class T> void allocOnly(T* deviceDest, size_t numElem)
{
cudaError_t errCode = cudaMalloc((void**)&deviceDest, numElem*sizeof(T));
if(errCode != cudaSuccess)
cout << "Got error with code " << errCode << endl;
}
int main()
{
float* test(0);
allocOnly<float>(test,10);
cout << "test = " << test << endl;
int deviceCount = 0;
cudaGetDeviceCount(&deviceCount);
cout << "deviceCount= " << deviceCount << endl;
float* test2(0);
cudaError_t errCode = cudaMalloc((void**)&test2, 10*sizeof(float));
if(errCode != cudaSuccess)
cout << "Got error with code " << errCode << endl;
cout << "test2 = " << test2 << endl;
return 0;
}