我正在運行下面的代碼。但是,我得到輸出 遇到錯誤代碼爲38 測試= 0 的deviceCount = 0 遇到錯誤代碼爲38 測試2 = 0 我在Ubuntu的NVIDIA GTX 690顯卡。這是否意味着駕駛員未被激活?cudaGetDeviceCount返回0
#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;
}
我不知道是否有幫助,但如果你是在最近的筆記本電腦運行Ubuntu,你可能需要,因爲Nvidia的擎天柱大黃蜂的,以便安裝驅動程序。 – Brugere