CUDA ptx file generation for driver API fails

Hi, I’ve been playing around with the driver API, but I’m having a problem with creating modules. Below is my code that loads the module:

int main() {
	CUDA_ASSERT(cuInit(0));

	// Device
	CUdevice device;
	CUDA_ASSERT(cuDeviceGet(&device, 0));

	// Context
	CUcontext context;
	CUDA_ASSERT(cuCtxCreate(&context, 0, device));

	// Module
	CUmodule module;
	CUDA_ASSERT(cuModuleLoad(&module, "kernel.ptx"));

	// Free context
	CUDA_ASSERT(cuCtxDestroy(context));
}

I have the following project structure:

project
* kernel.cu
* main.cpp

kernel.cpp looks like this (note that this is the entire file):

#include <cstdio>

__global__ void run_kernel() {
	printf("kernel running\n");
}

I have added the --ptx option to NVCC via Configuration Properties → CUDA/C++ → Command Line → Additional Options and I have linked against cuda.lib. I think I’ve done everything correctly, but whenever I compile I get an LNK1107 Invalid or corrupt file: cannot read at 0x8B1 error - how can I fix this? Thanks.

Solved it by using the following arguments: -Xcompiler “/wd 4819” --threads 0

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.