To get Optix version


how can I get the information, if the graphic card supports OptiX, and if so, which version?


You could do something like the CUDA device query example and get the Streaming Multiprocessor (SM) versions of the installed devices. Sample3 inside the OptiX SDK does something similar, enumerating the devices before creating a context.
The OptiX release notes document contains information about which SM versions are supported.
For single GPUs all SM versions from 1.0 to 5.2 are supported by OptiX 3.6.3, but there are some features which require at least SM 2.0, for example multi-GPU and some acceleration structure builders on the GPU.
Because of that I would recommend to test if the installed GPU to use with OptiX has at least SM 2.0 to be on the safe side.

Can I add to this: is it also sensible to check for a maximum SM version?

Suppose that in 2 years there’s a new generation of NVIDIA cards, which is not supported by an old OptiX version (such as was the case with Maxwell and 3.6). The application would then crash.

How can I add a reliable check in the sense of “Your graphics card is too new”?

True, that happened with Kepler and Maxwell. Forward compatibility is something which hopefully improves with future OptiX versions.
You could inform the user that the OptiX version your program uses is only officially supporting a known set of SM versions but I would not make this an end condition to enable the user to test if the application works after all.

I had the same question, as InformatikSuperheld.
And add to this: for example we use OptiX version 3.0.0 just now.
If the graphic card is “too new” , the application would be crash.
If the graphic card is “too old” (supports only version 2.6), application would be crash too.
I see no possibility to avoid crash at all.
Are there any possibility to get compatibility status (if OptiX version and the graphic card are compatible) without start OptiX-application (“from outside”)?

Without start OptiX application? You mean before the user starts the app, can they know whether it’s compatible? Yes. The list of supported devices for each OptiX version is in the release notes, and you can pass this info to your users.

Or did you mean at application runtime, before creating the OptiX context? This is also possible by querying the compute capability of the cards and not choosing the cards that are too new. Program your application to know which cards are too new, based on the release notes.