CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`
时间: 2023-09-25 18:15:03 浏览: 90
The `CUBLAS_STATUS_NOT_INITIALIZED` error occurs when you try to create a cuBLAS handle without initializing the cuBLAS library first. To resolve this issue, you need to make sure that you initialize the cuBLAS library before creating the handle.
Here's an example of how you can initialize the cuBLAS library and create a handle:
```cpp
#include <cublas_v2.h>
int main() {
cublasHandle_t handle;
cublasStatus_t status = cublasCreate(&handle);
if (status != CUBLAS_STATUS_SUCCESS) {
// Handle error
return status;
}
// Use the cuBLAS handle for further operations
// Destroy the cuBLAS handle when no longer needed
cublasDestroy(handle);
return 0;
}
```
Make sure to include the `cublas_v2.h` header file, and link against the cuBLAS library when compiling your code.
By following these steps, you should be able to resolve the `CUBLAS_STATUS_NOT_INITIALIZED` error.
阅读全文