Comments (8)
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.
from deepdrr.
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 ?
from deepdrr.
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
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.
from deepdrr.
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.
from deepdrr.
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.
from deepdrr.
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.
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
]
from deepdrr.
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
from deepdrr.
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.
from deepdrr.
Related Issues (20)
- [Question]About parallel beam and cone beam HOT 1
- mapping 3D points to 2D points
- mapping 2Dpoint to 3Dpoint HOT 3
- Projection Matrix HOT 1
- FLIP AXIS HOT 5
- How to implement STL to DCM transformation in deepdrr HOT 1
- How to set up a simulation of an orthogonal projection? HOT 1
- Isocenter / origin question HOT 1
- Given extrinsic matrix and intrinsic matrix HOT 10
- Zooming out on the DRR HOT 1
- Error when trying out the main branch HOT 7
- `TypeError` always raised when calling `Volume.from_dicom` without a cache_path
- Where does the formula for HU to density come from? HOT 1
- gpu utilization and performances HOT 5
- DRR is white. HOT 7
- cuMemcpyHtoD failed! HOT 6
- Error when compiling kernel (using the example python script) HOT 3
- Dead link to test data (used in Jupyter notebook)
- DEEPDRR Achieve gradient projection HOT 1
- Unexpected DRR orientation HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdrr.