A Language for Digital Objects

What does the word paged mean? Something book-like, or at least something with pages, that have fronts and backs, that can be turned or lie open; a pair of pages face each other across a divide or…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Ray Tracing with CUDA on Windows 10

Regarding some tech specs, I’m using Visual Studio 15.9.5 and CUDA 10, and a GeForce 960m GPU.

Initially, I wanted to create a CUDA runtime application with Visual Studio because I wrote the non-CUDA version ray-tracer with VS. There was compatibility issues with VS 2017 and latest version of CUDA before; but this project builds and runs fine with the tech specs I mentioned in the beginning, with some small issues I will mention below.

The set up was rather straight-forward. I’ll skip the CUDA installation here. With CUDA 10 installed, we can just create a new CUDA runtime project.

The second issue with VS is that the execution time is somehow significantly more than if I run the same code directly from command line. For the image that takes 23~ seconds to render, Visual Studio would probably take 2 to 3 minutes. If you know the reasons behind it, please comment and let me know 🙂

For the reasons mentioned above, I actually recommend not using Visual Studio. Just use whatever editor you prefer and run the following commands to compile and run.

After this you will probably see some warnings like the following

Don’t worry about it. This is because there is recursion in our code, which we do and so the stack size cannot be determined at compile time. Just run the executable and we would get results similar to the following:

We can do this through Nsignt Monitor. You probably need to run as administrator.

It’s NOT recommended to disable WDDM TDR completely. In this case I wasn’t sure how much time I need so I disable it just to run CUDA. I would also experiment with different delay time if you want to be safe.

The performance gain is such a relief. I have the following comparison:

Granted, though, it might not be a fair comparison for the CPU because my Visual Studio runs on single CPU core. There are probably ways to increase the number of cores used with Visual Studio, which I didn’t have time to explore. So from my looking around online, the runtime without CUDA ranges from couple minutes to more than half an hour for different people. Regardless, I think the improvement can make us happy.

The process was not as smooth as I’d expected, mostly due to platform issues, but the result is so worth it. I’m excited to explore more with CUDA in the near future 😀

Add a comment

Related posts:

FSTVLST di Proudphere Salatiga

Saya diajak teman yang die-hard untuk menonton tiap gigs FSTVLST, Anton namanya. Dia datang dari Solo — kota ia menimba ilmu. Mampir ke rumah untuk menjemput saya. Malam minggu itu, saya laptopan di…

Why doing right is not enough

No one is perfect. Have you thought about someone that you know is too perfect for being a human? Do sports, have friends and good connections, have time for everyone, have good grades for schools…