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

Compiling gridencoder on windows with cuda 12.5 #199

Open
Duodecimus opened this issue Jul 4, 2024 · 1 comment
Open

Compiling gridencoder on windows with cuda 12.5 #199

Duodecimus opened this issue Jul 4, 2024 · 1 comment

Comments

@Duodecimus
Copy link

this was a chore, but I got it working. compiled, at least.

first, setup some environment variables.
specifically, you need CUDA_ARCH to exist. you'll need to look up exactly what the value should be for your video card. my Nvidia 3050 is 'sm_86'
Some others that you might need are TCNN_CUDA_ARCHITECTURES which depends on your card again, mine is '86'
and also CUDA_HOME which should be the path to your cuda install

Start with downloading the repo, then navigate to torch-ngp\gridencoder and run python setup.py install

This will almost certainly fail. you'll probably get a bunch of errors about atomicAdd.
we needed to do this to generate a build.ninja file. it would be somewhere like \torch-ngp\gridencoder\build\temp.win-amd64-cpython-312\Release

edit the file.
you need to double check all the paths you see in here. mine failed to have correct paths for cuda and visual studio. there is also a reference to std=c++. make sure that you change this to a version you have installed. I used c++17
save the file

now open gridencoder.cu
near the top, around like 20 you'll see a definition for atomicadd

now, depending on the errors you get you'll need to be creative here, but basically we need to write a function to convert what is getting put into atomic add into what cuda 12.5 is expecting.
My errors looked like this:
function "atomicAdd(int *, int)" does not match because argument #1 does not match parameter
static __inline __declspec(__device__) int atomicAdd(int *address, int val)

so my functions ended up looking like this

__device__ inline at::Half atomicAdd(at::Half *address, at::Half val) {
return atomicAdd(address, val);
}

template <typename T>
__device__ inline T atomicAdd(T *address, T val) {
return atomicAdd(address, val);
}

now open a cmd window next to the build.ninja file and run ninja -f build.ninja

and then it compiled. yay

@Duodecimus
Copy link
Author

you may also need to edit setup.py to have the correct c++ versions and visual studio paths

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

1 participant