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

installation problem #26

Closed
s-elsheikh opened this issue Feb 3, 2021 · 8 comments · Fixed by #29
Closed

installation problem #26

s-elsheikh opened this issue Feb 3, 2021 · 8 comments · Fixed by #29

Comments

@s-elsheikh
Copy link

s-elsheikh commented Feb 3, 2021

Hello,
I am really interested in using your program, but I keep getting an error when trying the example script.
The first error is in this line:
carm = deepdrr.CArm(isocenter=center)
I get this error : TypeError: init() missing 1 required positional argument: 'isocenter_distance'

So I add a random value of 800 to read : carm = deepdrr.CArm(isocenter=center, isocenter_distance=800)

and it runs. But in this line a get a long error message:
CompileError: nvcc compilation of C:\Users\Samer\AppData\Local\Temp\tmprdw5qsft\kernel.cu failed
[command: nvcc --cubin -D NUM_MATERIALS=3 -arch sm_75 -m64 -IC:\Users\Samer\anaconda3\envs\deepdrr2\Lib\site-packages\deepdrr\projector\cubic -Ic:\users\samer\anaconda3\envs\deepdrr2\lib\site-packages\pycuda\cuda kernel.cu]
[stdout:
kernel.cu(351): error: expected an expression

kernel.cu(363): error: expected an expression

kernel.cu(371): error: expected an expression

kernel.cu(324): warning: variable "px" was set but never used

kernel.cu(324): warning: variable "py" was set but never used

kernel.cu(324): warning: variable "pz" was set but never used

kernel.cu(327): warning: variable "boundary_factor" was set but never used

3 errors detected in the compilation of "kernel.cu".
kernel.cu
]

Some Information about my system. I am running python 3.9 under windows 10 through a jupyter Notebook.
I have CUDA 11 installed. I tried using pycuda (https://documen.tician.de/pycuda/tutorial.html) And I had no errors.
I can run tensorflow CNN on my machine without errors edit: (in R).

edit: I also added the path to cl.exe to the envoronment variables.

I would be very thankful if you could you maybe help find where this error is coming from.

@mathiasunberath
Copy link
Collaborator

Is it possible that you have a version conflict between your nvcc provided by Visual Studio and Cuda, e.g. as described here: https://stackoverflow.com/questions/48170231/cuda-c-expected-an-expression-in-kernel-cu-file ?

@s-elsheikh
Copy link
Author

s-elsheikh commented Feb 4, 2021

Hello,
Thanks for the tip. I checked the version compatibility and it should be compatible.
Visual studio 16.8.2 / CUDA 11.0
I also tested compiling the sample files in the CUDA sample folder, all were sucessful.

I then opend a test file in visual studio, saved it and compiled it and it ran successfuly
Screenshot 2021-02-04 214723

I think it is probably something else.

I also had multiple installations of cuda( 11, 11.1 and 11.2) I removed them and reinstalled 11.0.

I thank you for your help.

@mathiasunberath
Copy link
Collaborator

Have you tried compiling the DeepDRR kernels though? It seems that the issue is somewhere in the compatibility with some calls within the INTERPOLATE function. If you have a way to increase verbosity of your outputs you may also find some more helpful pointers.

@benjamindkilleen
Copy link
Member

I've had similar bugs before. What version of gcc is on you path? We use macros to enable some features, which may not work with every C compiler.

@s-elsheikh
Copy link
Author

Hello,
First I apologise for the long response times. I am trying this on my home computer, so I can only reponse or troubleshoot in the evinings.

@mathiasunberath About verbosity I owe you an apology. THe error message in Jupyter notebook is longer, but I thought the line numbers would be enough. I will copy the complete error message at the end of this message.

As you may have guessed I am a relative noob. So I will write down what I tried:
I tried compiling the kernel.cu file in the temp directory"nvcc compilation of C:\Users\Samer\AppData\Local\Temp\tmp4lbohdb3\kernel.cu".
But I got te tresponse: "fatal error C1083: Cannot open include file: 'cubicTex3D.cu': No such file or directory".
So I moved the kernel.cu file into this folder"C:\Users\Samer\anaconda3\envs\deepdrr2\Lib\site-packages\deepdrr\projector\cubic" and tried compiling again and again I got the same response: No such file or directory

I will try further tonight and come back to you if I get any further.

@benjamindkilleen

I installed gcc-core, gcc debug info, gcc fortran, gcc g++, gcc objc and gcc objc ++ version 9.3.0-2 using cygwin installer. Install location is in c: and the c:\cygwin64\bin is added to the user path. I tested the gcc version from the command prompt and I got a reponse.

Thank you for your assistance.

The complete error message (of the last step of the example script):

CompileError Traceback (most recent call last)
in
----> 1 with deepdrr.Projector(volume, camera_intrinsics, carm) as projector:
2 projection = projector()

~\anaconda3\envs\deepdrr2\lib\site-packages\deepdrr\projector\projector.py in init(self, volume, camera_intrinsics, carm, step, mode, spectrum, add_scatter, add_noise, photon_count, threads, max_block_index, collected_energy, neglog)
106
107 # compile the module
--> 108 self.mod = _get_kernel_projector_module(self.num_materials) # TODO: make this not a compile-time option.
109 self.project_kernel = self.mod.get_function("projectKernel")
110

~\anaconda3\envs\deepdrr2\lib\site-packages\deepdrr\projector\projector.py in _get_kernel_projector_module(num_materials)
43
44 # TODO: replace the NUM_MATERIALS junk with some elegant meta-programming.
---> 45 return SourceModule(source, include_dirs=[bicubic_path], no_extern_c=True, options=['-D', f'NUM_MATERIALS={num_materials}'])
46
47

~\anaconda3\envs\deepdrr2\lib\site-packages\pycuda\compiler.py in init(self, source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs)
288 self._check_arch(arch)
289
--> 290 cubin = compile(source, nvcc, options, keep, no_extern_c,
291 arch, code, cache_dir, include_dirs)
292

~\anaconda3\envs\deepdrr2\lib\site-packages\pycuda\compiler.py in compile(source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs, target)
252 options.append("-I"+i)
253
--> 254 return compile_plain(source, options, keep, nvcc, cache_dir, target)
255
256

~\anaconda3\envs\deepdrr2\lib\site-packages\pycuda\compiler.py in compile_plain(source, options, keep, nvcc, cache_dir, target)
133 "encountered an error")
134 from pycuda.driver import CompileError
--> 135 raise CompileError("nvcc compilation of %s failed" % cu_file_path,
136 cmdline, stdout=stdout.decode("utf-8", "replace"),
137 stderr=stderr.decode("utf-8", "replace"))

CompileError: nvcc compilation of C:\Users\Samer\AppData\Local\Temp\tmpyoq75wm0\kernel.cu failed
[command: nvcc --cubin -D NUM_MATERIALS=3 -arch sm_75 -m64 -IC:\Users\Samer\anaconda3\envs\deepdrr2\Lib\site-packages\deepdrr\projector\cubic -Ic:\users\samer\anaconda3\envs\deepdrr2\lib\site-packages\pycuda\cuda kernel.cu]
[stdout:
kernel.cu(351): error: expected an expression

kernel.cu(363): error: expected an expression

kernel.cu(371): error: expected an expression

kernel.cu(324): warning: variable "px" was set but never used

kernel.cu(324): warning: variable "py" was set but never used

kernel.cu(324): warning: variable "pz" was set but never used

kernel.cu(327): warning: variable "boundary_factor" was set but never used

3 errors detected in the compilation of "kernel.cu".
kernel.cu
]

@maxrohleder
Copy link
Contributor

maxrohleder commented Mar 25, 2021

After installing the project via pip install -e deepdrr and running the example, I get the same errors from the cuda kernel. With my current setup, I am running the old deepdrr version (Version 0.1) without problems. Just thought I would add this to the record until I or someone else finds a solution.

Setup:

  • Windows 10
  • Cuda 10.2 (nvcc v10.2.89)
  • MSVC 19.00.24215 (from Visual Studio 2015 v14.0 which is suitable for Cuda 10.2 according to this)

Also same error with this setup:

  • Windows 10
  • Cuda 11.2 (nvcc v11.2.152)
  • MSVC 19.28.29913 (from Visual Studio 2019 v16.9)

Both Cuda installations were tested against the examples from the respective installation. Was the framework tested against windows? If yes, what were the respective versions of the cuda and cpp compilers used?

The errors in the cuda code occur where ever the macro INTERPOLATE is used. I suspect, that the compile chains I have tested dont resolve the macros right. Maybe, some preprocessor directives are not set right for windows...

Edit:
I used the --preprocess (-E) flag with the nvcc command that threw the error to inspect if the macros were resolved correctly.

nvcc --cubin -D NUM_MATERIALS=3 -arch sm_75 -m64 -E -IC:\Users\max\Documents\deepdrr\deepdrr\projector\cubic -Ic:\users\max\miniconda3\envs\deepdrr\lib\site-packages\pycuda\cuda C:\Users\max\AppData\Local\Temp\tmpnusjoa2s\kernel.cu

See the preprocessed code here: preprocessed_kernel_cud11_msvc192.txt (renamed to .txt for github)

I am not an expert in cpp and macros, but the macro from kernel.cu(363)

INTERPOLATE(0.5 * lastStepsize);

was resolved to

({
    ({ output[idx + (0)] += (0.5 * lastStepsize) * tex3D(volume, px, py, pz) * round(cubicTex3D(seg_0, px, py, pz));}); 
    ({ output[idx + (1)] += (0.5 * lastStepsize) * tex3D(volume, px, py, pz) * round(cubicTex3D(seg_1, px, py, pz));}); 
    ({ output[idx + (2)] += (0.5 * lastStepsize) * tex3D(volume, px, py, pz) * round(cubicTex3D(seg_2, px, py, pz));});
});

, which looks okay to me. (I added in the line breaks and indents for readability in this post) I am not sure about all the brackets and if that would make the compiler think its not an expression, hence the error. But the preprocessing seems to work and I dont think this would be different with gcc, which the readme stated to use.

So still no idea what the problem is. Hope this helps someone else.

Thanks for the help in advance,
Max

maxrohleder pushed a commit to maxrohleder/deepdrr that referenced this issue Mar 26, 2021
The parenthesis in the macro UPDATE and INTERPOLATE
are causing problems when compiling on windows.
See arcadelab#26
for more details.
@benjamindkilleen
Copy link
Member

It looks like the pull request found the problem in the INTERPOLATE macro in the cuda kernel. I suspect there is a difference between Windows and Linux here. Thanks for the pull request! I will take a look.

@maxrohleder
Copy link
Contributor

Yes it looks like a Win/Linux thing! Please let me know if you find out the root problem, I would very much be interested in that!

As you can see in the proposed changes, the () parentheses encapsulating the whole macro definitions cause the problem on windows. The preprocessed code still contains the outmost parentheses, which causes the compiler to identify the respective line not as an expression, but as something else... I suspect the ()-symbols are defined as operators or casting keywords and hence are not taken into account by the compiler.

Why this works on Linux and not on Windows, I have no clue.

Bear in mind, that this change was only tested against cuda 11.2 and 10.2 and their respective host cpp compilers (MSVC 192x and 190x if I remember correctly). Please make sure it does not break your linux setup.

maxrohleder pushed a commit to maxrohleder/deepdrr that referenced this issue Apr 6, 2021
The parenthesis in the macro UPDATE and INTERPOLATE
are causing problems when compiling on Windows.

See arcadelab#26
for more details.

This is a second pull request, as the changes in
arcadelab#29 got lost by mistake.
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

Successfully merging a pull request may close this issue.

4 participants