Optix SDK examples cannot run on my Computer.
Then I tested with the below simple code.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <optix.h>
#include <sutil.h>
int main(int argc, char *argv[])
{
RTcontext context;
RTbuffer buffer;
RT_CHECK_ERROR(rtContextCreate(&context));
/*Buffer*/
RTvariable var_buffer;
RT_CHECK_ERROR(rtBufferCreate(context, RT_BUFFER_OUTPUT, &buffer));
RT_CHECK_ERROR(rtBufferSetFormat(buffer, RT_FORMAT_FLOAT4));
RT_CHECK_ERROR(rtBufferSetSize2D(buffer, 256u, 256u));
RT_CHECK_ERROR(rtContextDeclareVariable(context, "result_buffer", &var_buffer));
RT_CHECK_ERROR(rtVariableSetObject(var_buffer,buffer));
/*EntryPoint and Raytype*/
RT_CHECK_ERROR(rtContextSetRayTypeCount(context,1));
RT_CHECK_ERROR(rtContextSetEntryPointCount(context,1));
/*Program*/
char path_to_ptx[512];
RTprogram ray_gen_program;
RTvariable draw_color;
sprintf(path_to_ptx, "%s/%s", sutilSamplesPtxDir(), "sample3_generated_draw_color.cu.ptx");//draw_color.cu is copied from SDK sample1
RT_CHECK_ERROR(rtProgramCreateFromPTXFile(context,path_to_ptx, "draw_solid_color",&ray_gen_program));
RT_CHECK_ERROR(rtProgramDeclareVariable(ray_gen_program, "draw_color",&draw_color));
RT_CHECK_ERROR(rtVariableSet3f(draw_color,0.462f,0.725f,0.0f));
RT_CHECK_ERROR(rtContextSetRayGenerationProgram(context,0,ray_gen_program));
/*Run*/
RT_CHECK_ERROR(rtContextValidate(context));
RT_CHECK_ERROR(rtContextCompile(context));
RT_CHECK_ERROR(rtContextDestroy(context));
return 0;
}
Without,
RT_CHECK_ERROR(rtContextCompile(context));
, the code compiles and runs normally. But with that line, the code compiles normally but runs with the error:
OptiX Error: Invalid context (Details: Function “RTresult _rtContextCompile(RTcontext)” caught exception: Unable to set the CUDA device., [3735714])
(/home/jlmiao/NVIDIA-OptiX-SDK-3.6.0-linux64/SDK/sample3/sample3.c:147)
OS: Linux smithwick 3.5.0-51-generic #76-Ubuntu SMP Thu May 15 21:19:10 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
CPU: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz
GPU: GeForce GTX 480; Tesla C2070
OptiX: 3.6.0
CUDA: release 5.5, V5.5.0
How to view the display driver version?
EDIT
$ nvidia-smi
Thu Jul 24 16:45:59 2014
±-----------------------------------------------------+
| NVIDIA-SMI 5.319.82 Driver Version: 319.82 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla C2070 Off | 0000:06:00.0 Off | Off |
| 45% 83C P8 N/A / N/A | 11MB / 6143MB | 0% Default |
±------------------------------±---------------------±---------------------+
| 1 GeForce GTX 480 Off | 0000:0A:00.0 N/A | N/A |
| 44% 47C N/A N/A / N/A | 81MB / 1535MB | N/A Default |
±------------------------------±---------------------±---------------------+
±----------------------------------------------------------------------------+
| Compute processes: GPU Memory |
| GPU PID Process name Usage |
|=============================================================================|
| 1 Not Supported |
±----------------------------------------------------------------------------+