Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Windows machine #7

Closed
tim37021 opened this issue Dec 4, 2018 · 17 comments
Closed

Build on Windows machine #7

tim37021 opened this issue Dec 4, 2018 · 17 comments

Comments

@tim37021
Copy link

tim37021 commented Dec 4, 2018

Build script is target on gcc and linux currently.
Is there any plan to port to Windows and MSVC?

@tim37021
Copy link
Author

tim37021 commented Dec 4, 2018

for M_PI is not defined:
#define _USE_MATH_DEFINES

And this line can't be compiled with MSVC. variadic macro here is non-standard. replace args VA_ARGS here to resolve error.

#define DISPATCH(use_gpu, f, args...) \

image

@BachiLi
Copy link
Owner

BachiLi commented Dec 4, 2018

Thanks for the report!
I plan to handle windows build within a few months.
Testing CUDA support on windows might be tricky though due to me lacking machines.
Contribution is welcome any time ; )

@tim37021
Copy link
Author

tim37021 commented Dec 5, 2018

@BachiLi I am still working on it.
On my Windows machine with miniconda 3. After some modification to code and cmake script. I can successfully build a redner.dll now.
But fail to install redner into python 3.6 in conda environment.(pyredner is installed successfully)

@swordigo1995
Copy link

@tim37021 I also fail to import redner.dll into python3.6 in conda environment, in the same situation with yours. "ImportError: DLL load failed: The specified module could not be found." is reported by python.
Do you have any solution for this problem?

@BachiLi
Copy link
Owner

BachiLi commented Dec 9, 2018

I think it has to do with the fact that I did not link the Python libraries while building. This can cause problems on windows. For now you can try adding ${Python_LIBRARIES} in target_link_libraries() and see if it works. I'll take a look once I get a windows machine.

@tim37021
Copy link
Author

tim37021 commented Dec 9, 2018

@swordigo1995 other dependencies dlls(embree3.dll, tbb.dll, tbb_malloc.dll) are also missed when importing redner.

@BachiLi
how about including pybind11 in this repo as a submodule?
cmake script does not check pybind11 installation at all.
target_include_directores(redner pybind11/include)

btw, I've successfully built and tested on linux
conda python 3.7.1, CUDA 10 OptiX, Pytorch(CUDA 10)

@swordigo1995
Copy link

@tim37021 @BachiLi Thanks a lot for your advice!! 👍
I copied other dependencies to the same folder with redner.pyd when importing redner, and it works! But I got another error when it initializes redner.Scene class in the forward() func.
@tim37021 Do you have successfully test it on Windows? If not, I think it's time for me to setup a linux environment..

$ python tutorials/01_optimize_single_triangle.py
Traceback (most recent call last):
File "tutorials/01_optimize_single_triangle.py", line 97, in
img = render(0, *scene_args)
File "D:\Anaconda3\envs\redner\lib\site-packages\pyredner\render_pytorch.py", line 216, in forward
pyredner.get_use_gpu())
RuntimeError: Caught an unknown exception!

@tim37021
Copy link
Author

@swordigo1995 I switched to linux quickly when I've failed on windows. On linux some modifications are still necessary to get it work. And you need to build pytorch on your own for using CUDA 10.

@ankur6ue
Copy link

Would be great to have a windows build working.. Not sure why windows always get the short shrift. Lots of ML practitioners still use windows, particularly those from a graphics background.

@BachiLi
Copy link
Owner

BachiLi commented Feb 2, 2019

Check out #11

@mworchel
Copy link
Contributor

mworchel commented Dec 3, 2019

Just FYI, I'm currently working on Windows compatibility. I added prebuild windows binaries to the dependencies, adapted the imports of embree and optix and implemented MSVC replacements for the GCC intrinsics. I was able to compile Redner using Visual Studio 2019 today and successfully interfaced with the renderer using the Python bindings.

@BachiLi
Copy link
Owner

BachiLi commented Dec 12, 2019

Just FYI, I'm currently working on Windows compatibility. I added prebuild windows binaries to the dependencies, adapted the imports of embree and optix and implemented MSVC replacements for the GCC intrinsics. I was able to compile Redner using Visual Studio 2019 today and successfully interfaced with the renderer using the Python bindings.

This is merged. GPU support still needs some work so not closing this issue yet. I also need to figure out a way to publish windows pip packages.

@mworchel
Copy link
Contributor

mworchel commented Dec 13, 2019

This is merged. GPU support still needs some work so not closing this issue yet. I also need to figure out a way to publish windows pip packages.

Thanks for merging! I will look into GPU support the next weeks. At least in theory it shouldn't be too hard.

EDIT: Ok, the problem with using CUDA as language is that you cannot compile cpp files with NVCC that way. That's probably the issue you've run into.

EDIT 2: I was able to compile the GPU version on Windows and get it running. I figured, it would be easiest to modify the pybind scripts, so introducing a new function called pybind11_setup_module that does all the steps pybind11_add_module does, except for the add_library call. I don't like the idea of maintaining our own fork of pybind, so it's probably best to supply the code as extra CMake script.

@guanming001
Copy link

Thank you for the excellent work!

I am able to build and run the forward rendering examples on Windows successfully.
But it will be stuck at the backpropagation of the gradient step.

Are there any updates on how to run with GPU version on Windows?

@mworchel
Copy link
Contributor

mworchel commented Jan 15, 2020

I am able to build and run the forward rendering examples on Windows successfully.

That's great news!

But it will be stuck at the backpropagation of the gradient step.

This is however not. Tbh, I didn't try the backprop samples under Windows yet but a functional backpropagation is also crucial for my use case. So I will probably also run into this issue soon, thanks for the warning.

Are there any updates on how to run with GPU version on Windows?

I managed to get the GPU version to compile under Windows and also built the python package. From what I've tested, deferred rendering works as expected but path tracing does not. Essentially something triggers a segmentation fault. I did dive deeper into the issue and traced it back to cudaDeviceSynchronize call failing in a thrust function. Unfortunately, this can be caused by any previous cuda call, so I wasn't yet able to pin down the exact location of the cause.

For now, I find a fully working CPU version more important, so I'll probably look into that first.

EDIT: You are right. Backpropagation does not work under Windows. Created an issue (#93).

@mworchel
Copy link
Contributor

mworchel commented Feb 3, 2020

@guanming001 GPU support is now added for Windows builds. Unfortunately, path tracing currently does not work, but at least the albedo and deferred rendering operations (as well as backpropagation with these).

If you encounter weird linking issues (e.g. VS trying to link against optimized.lib), then try to patch pybind11 with these changes pybind/pybind11#2104. It's a bug on their side.

BachiLi added a commit that referenced this issue Mar 17, 2020
TensorFlow support WIP. This should addresses
#7 and
#93
@BachiLi
Copy link
Owner

BachiLi commented Mar 17, 2020

Windows machines should be able to pip install redner-gpu and pip install redner from now on. TensorFlow is not supported yet due to some compilation issues (MSVC is not happy with the TensorFlow headers).

@BachiLi BachiLi closed this as completed Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants