Hi
I have started to use CUDA and have run in to a strange problem. Im using CUDA.NET, and this is what I have done.
- The SDK project Transpose for transposing matrices have been compiled to a cubin using:
[codebox]echo off
setlocal EnableDelayedExpansion
REM ******************************************************
REM Batch script for building CUDA code files
REM ******************************************************
REM if we haven’t yet set up the VS build environment, do so here
if “%DevEnvDir%” EQU “” (
call “C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat”
)
if “%1” EQU “” (
echo.
echo Usage:
echo.
echo %0 ^<codefile.cu^>
echo.
echo This batch script compiles .cu files into executables.
echo.
goto :EOF
)
REM get the base file name from the input file name
for %%a in (%1) do @set CUFILE=%%~na
if not exist %CUFILE%.cu (
echo File not found.
goto :EOF
)
echo Building %CUFILE%.cu …
nvcc %CUFILE%.cu --cubin -I “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include” -I “C:\ProgramData\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc” -arch sm_11
:EOF
endlocal[/codebox]
- Running the following code fails at iteration 16636 (each time):
[codebox]dev = new CUDA(0, true);
for (int i = 0; i < 120000; i++)
{
CUResult f = CUDADriver.cuModuleLoad(ref mod1, @“C:\Users\Brian Christensen\Documents\Visual Studio 2008\Projects\cimic\cimic.CUDA\CUDA_FILES\Matrix\transpose.cubin”);
CUDADriver.cuModuleUnload(mod1);
}[/codebox]
And so does the code:
[codebox]dev = new CUDA(0, true);
for (int i = 0; i < 120000; i++)
{
CUmodule mod1 = dev.LoadModule(@“C:\Users\Brian Christensen\Documents\Visual Studio 2008\Projects\cimic\cimic.CUDA\CUDA_FILES\Matrix\transpose.cubin”);
dev.UnloadModule(mod1);
}[/codebox]
The error I’m getting is a: AccesCiolationException that says that it was tried to read/write in a protected memory. This can often be a sign of damaged memory
If I destroy the context, and creates it again every 16635 iteration (just before the error), it runns through without any errors
[codebox]if(i % 16635 == 0)
{
dev.DestroyContext();
dev.CreateContext(0);
}[/codebox]
I wanted to try to see if it was caused by the CUDA wrapper by creating some code that did the cuda stuff in runtime api, but I have not succeded (I am new to this, and have only used CUDA.NET)
Can anybody help me with finding the problem? Maybe help me testing if its the cuda wrapper or the cuda framework, am I missing something? Hope not that my memory is corrupt :(