kunzmi / managedCuda

ManagedCUDA aims an easy integration of NVidia's CUDA in .net applications written in C#, Visual Basic or any other .net language.
Other
440 stars 79 forks source link

ErrorInvalidPtx: This indicates that a PTX JIT compilation failed. #68

Open Axelarate opened 5 years ago

Axelarate commented 5 years ago

Hello! Am a complete beginner with GPGPU and kernels, now that that is out of the way, here goes. Been trying to adapt ManagedCuda in my project but am stuck in already the first steps... After copying the sample cuda kernel and slightly adjusting it(literally just changed the name only) extern "C" { // Device code __global__ void Ker(const float* A, const float* B, float* C, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N) C[i] = A[i] + B[i] / 2; } } Afterwards compiling it trough nvcc command line nvcc TestKer.cu -ptx it compiles to a TestKer.ptx file but with a warning: c:\program files\nvidia gpu computing toolkit\cuda\v10.0\include\crt/device_functions.h: warning C4819: The file contains a character that cannot be represented in the current code page (1257). Save the file in Unicode format to prevent data loss afterwards trying to load the kernel trough string path = GifferStartFunctions.KernelFolder + "/TestKer.ptx"; CudaContext context = new CudaContext(0); CudaKernel kernel = context.LoadKernel(path, "Ker"); it gives out this magnificent error CudaException: ErrorInvalidPtx: This indicates that a PTX JIT compilation failed. This was the point where i can't find any answers searching google and am desperate enough to write for help... If this is not the place for me to ask help i apologize, but i am at wits end trying to figure this out without any success

kunzmi commented 5 years ago

hmm, already the warning during compilation is strange. Are you sure to use all tools with the correct code page? Do the original Cuda sample compile?

Axelarate commented 5 years ago

hmm, already the warning during compilation is strange. Are you sure to use all tools with the correct code page? Do the original Cuda sample compile?

I thought it was strange but am getting the same warning compiling the sample. Am using Cuda 10 toolkit and 2017VS C++ toolkit. Have no idea if something else is even needed to compile it correctly... Sad part is that the 2017VS C++ toolkit has 4 cl.exe but so far haven't had luck running the sample trough any of them, both x64 versions get me this one warning, both x86 versions give me 76 errors and the same warning at start... almost all errors are class template "std::_Is_memfunptr" has already been defined the rest are first parameter of allocation function must be of type "size_t" or similar to those both

Axelarate commented 5 years ago

Tried again to compile it with Cuda9 with 2015VS C++ toolkit, same error. Tried saving the .cu file with all Unicode formats it provided me, same warnings on all files. Can anyone direct me to how they compile their .cu files to .ptx files or am i missing some assembly or anything, i literally have 0 ideas how to proceed with this...

TimurVizaev commented 5 years ago

I am having same issue, using Cuda10.1, VS2015, any ideas?

TimurVizaev commented 5 years ago

Ok, my particular issue was that there was a mix of CUDA 10.0 and 10.1 on same machine. After cleaning and adjusting some dependencies it is working appropriately.

Axelarate commented 5 years ago

My issue was that CUDA 10 doesn't support my GPU anymore and had a mix of 9/10 while testing with CUDA 9 + ain't sure about driver update then. So to anyone with this issue:

  1. Check if your GPU is compatible with the CUDA your using,
  2. Check if you have the newest drivers up for your GPU.
eduardobellotto commented 4 years ago

In my case, the solution was the following:

In Visual Studio Project Properties, CUDA C/C++ menu, Device option, there is a field called Code Generation.

As my GPU is GeForce GT 720, it has Kepler architecture and the values must be compute_35,sm_35.

The architecture of your GPU can be found in the specifications (Google it) and the specific sm (streaming multiprocessor) version can be found in this page.

Best regards.

chenw11 commented 3 years ago

In my case, I have to change the Platform Toolsetin the CUDA project property from Visual Studio2019(v142) to VisualStudio2017 (v141), and also change the Windows SDK version from 10.0 to 8.1 image